From 3691e59af1b5ab0857db07059ce5eb4f19c68a35 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Fri, 11 Aug 2023 13:16:53 +0800 Subject: [PATCH 1/5] Expose MessageLimit as a configuration --- cmd/serve.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/serve.go b/cmd/serve.go index 87b83dda..febaf52f 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -99,6 +99,7 @@ var flagsServe = append( altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-file", Aliases: []string{"web_push_file"}, EnvVars: []string{"NTFY_WEB_PUSH_FILE"}, Usage: "file used to store web push subscriptions"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-email-address", Aliases: []string{"web_push_email_address"}, EnvVars: []string{"NTFY_WEB_PUSH_EMAIL_ADDRESS"}, Usage: "e-mail address of sender, required to use browser push services"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-startup-queries", Aliases: []string{"web_push_startup_queries"}, EnvVars: []string{"NTFY_WEB_PUSH_STARTUP_QUERIES"}, Usage: "queries run when the web push database is initialized"}), + altsrc.NewIntFlag(&cli.IntFlag{Name: "message-limit", Aliases: []string{"message_limit"}, EnvVars: []string{"NTFY_MESSAGE_LIMIT"}, Value: server.DefaultMessageLengthLimit, Usage: "size limit for the mesasge in bytes"}), ) var cmdServe = &cli.Command{ @@ -189,6 +190,7 @@ func execServe(c *cli.Context) error { metricsListenHTTP := c.String("metrics-listen-http") enableMetrics := c.Bool("enable-metrics") || metricsListenHTTP != "" profileListenHTTP := c.String("profile-listen-http") + mesasgeLimit := c.Int("message-limit") // Check values if firebaseKeyFile != "" && !util.FileExists(firebaseKeyFile) { @@ -364,6 +366,7 @@ func execServe(c *cli.Context) error { conf.WebPushFile = webPushFile conf.WebPushEmailAddress = webPushEmailAddress conf.WebPushStartupQueries = webPushStartupQueries + conf.MessageLimit = mesasgeLimit // Set up hot-reloading of config go sigHandlerConfigReload(config) From 6bd887537509fa9fccd0781ecde38e3faba993de Mon Sep 17 00:00:00 2001 From: zhzy0077 Date: Mon, 21 Aug 2023 11:51:48 +0800 Subject: [PATCH 2/5] fix typo and update docs --- cmd/serve.go | 4 ++-- docs/config.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index febaf52f..ef56f97b 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -190,7 +190,7 @@ func execServe(c *cli.Context) error { metricsListenHTTP := c.String("metrics-listen-http") enableMetrics := c.Bool("enable-metrics") || metricsListenHTTP != "" profileListenHTTP := c.String("profile-listen-http") - mesasgeLimit := c.Int("message-limit") + messasgeLimit := c.Int("message-limit") // Check values if firebaseKeyFile != "" && !util.FileExists(firebaseKeyFile) { @@ -366,7 +366,7 @@ func execServe(c *cli.Context) error { conf.WebPushFile = webPushFile conf.WebPushEmailAddress = webPushEmailAddress conf.WebPushStartupQueries = webPushStartupQueries - conf.MessageLimit = mesasgeLimit + conf.MessageLimit = messasgeLimit // Set up hot-reloading of config go sigHandlerConfigReload(config) diff --git a/docs/config.md b/docs/config.md index 9af79992..0f33ec3d 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1341,6 +1341,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`). | `web-push-file` | `NTFY_WEB_PUSH_FILE` | *string* | - | Web Push: Database file that stores subscriptions | | `web-push-email-address` | `NTFY_WEB_PUSH_EMAIL_ADDRESS` | *string* | - | Web Push: Sender email address | | `web-push-startup-queries` | `NTFY_WEB_PUSH_STARTUP_QUERIES` | *string* | - | Web Push: SQL queries to run against subscription database at startup | +| `message-limit` | `NTFY_MESSAGE_LIMIT` | *number* | - | The size limit (in bytes) for the ntfy message. NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increases this size limit, FCM and APNS will NOT work for large messages. | The format for a *duration* is: `(smh)`, e.g. 30s, 20m or 1h. The format for a *size* is: `(GMK)`, e.g. 1G, 200M or 4000k. From 6a3f169a4770db61b5826b2d56e6027d0eac94f2 Mon Sep 17 00:00:00 2001 From: zhzy0077 Date: Mon, 21 Aug 2023 11:55:20 +0800 Subject: [PATCH 3/5] fix typo. --- cmd/serve.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index ef56f97b..ac946e9c 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -190,7 +190,7 @@ func execServe(c *cli.Context) error { metricsListenHTTP := c.String("metrics-listen-http") enableMetrics := c.Bool("enable-metrics") || metricsListenHTTP != "" profileListenHTTP := c.String("profile-listen-http") - messasgeLimit := c.Int("message-limit") + messageLimit := c.Int("message-limit") // Check values if firebaseKeyFile != "" && !util.FileExists(firebaseKeyFile) { @@ -366,7 +366,7 @@ func execServe(c *cli.Context) error { conf.WebPushFile = webPushFile conf.WebPushEmailAddress = webPushEmailAddress conf.WebPushStartupQueries = webPushStartupQueries - conf.MessageLimit = messasgeLimit + conf.MessageLimit = messageLimit // Set up hot-reloading of config go sigHandlerConfigReload(config) From f565302a0fac93984d08314836d0ef5500a48bb6 Mon Sep 17 00:00:00 2001 From: zhzy0077 Date: Mon, 21 Aug 2023 11:56:31 +0800 Subject: [PATCH 4/5] Fix typo --- docs/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config.md b/docs/config.md index 0f33ec3d..bd1cac95 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1341,7 +1341,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`). | `web-push-file` | `NTFY_WEB_PUSH_FILE` | *string* | - | Web Push: Database file that stores subscriptions | | `web-push-email-address` | `NTFY_WEB_PUSH_EMAIL_ADDRESS` | *string* | - | Web Push: Sender email address | | `web-push-startup-queries` | `NTFY_WEB_PUSH_STARTUP_QUERIES` | *string* | - | Web Push: SQL queries to run against subscription database at startup | -| `message-limit` | `NTFY_MESSAGE_LIMIT` | *number* | - | The size limit (in bytes) for the ntfy message. NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increases this size limit, FCM and APNS will NOT work for large messages. | +| `message-limit` | `NTFY_MESSAGE_LIMIT` | *number* | - | The size limit (in bytes) for the ntfy message. NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increase this size limit, FCM and APNS will NOT work for large messages. | The format for a *duration* is: `(smh)`, e.g. 30s, 20m or 1h. The format for a *size* is: `(GMK)`, e.g. 1G, 200M or 4000k. From 6a10bac017ddfd400635f552cd421235cac9d99f Mon Sep 17 00:00:00 2001 From: zhzy0077 Date: Fri, 8 Sep 2023 13:21:55 +0800 Subject: [PATCH 5/5] Update template server.yml --- cmd/serve.go | 2 +- docs/config.md | 2 +- server/server.yml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index ac946e9c..5864fa46 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -99,7 +99,7 @@ var flagsServe = append( altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-file", Aliases: []string{"web_push_file"}, EnvVars: []string{"NTFY_WEB_PUSH_FILE"}, Usage: "file used to store web push subscriptions"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-email-address", Aliases: []string{"web_push_email_address"}, EnvVars: []string{"NTFY_WEB_PUSH_EMAIL_ADDRESS"}, Usage: "e-mail address of sender, required to use browser push services"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-startup-queries", Aliases: []string{"web_push_startup_queries"}, EnvVars: []string{"NTFY_WEB_PUSH_STARTUP_QUERIES"}, Usage: "queries run when the web push database is initialized"}), - altsrc.NewIntFlag(&cli.IntFlag{Name: "message-limit", Aliases: []string{"message_limit"}, EnvVars: []string{"NTFY_MESSAGE_LIMIT"}, Value: server.DefaultMessageLengthLimit, Usage: "size limit for the mesasge in bytes"}), + altsrc.NewIntFlag(&cli.IntFlag{Name: "message-limit", Aliases: []string{"message_limit"}, EnvVars: []string{"NTFY_MESSAGE_LIMIT"}, Value: server.DefaultMessageLengthLimit, Usage: "size limit for the message in bytes"}), ) var cmdServe = &cli.Command{ diff --git a/docs/config.md b/docs/config.md index bd1cac95..23dbeb82 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1341,7 +1341,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`). | `web-push-file` | `NTFY_WEB_PUSH_FILE` | *string* | - | Web Push: Database file that stores subscriptions | | `web-push-email-address` | `NTFY_WEB_PUSH_EMAIL_ADDRESS` | *string* | - | Web Push: Sender email address | | `web-push-startup-queries` | `NTFY_WEB_PUSH_STARTUP_QUERIES` | *string* | - | Web Push: SQL queries to run against subscription database at startup | -| `message-limit` | `NTFY_MESSAGE_LIMIT` | *number* | - | The size limit (in bytes) for the ntfy message. NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increase this size limit, FCM and APNS will NOT work for large messages. | +| `message-limit` | `NTFY_MESSAGE_LIMIT` | *number* | - | The size limit (in bytes) for a ntfy message. NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increase this size limit, FCM and APNS will NOT work for large messages. | The format for a *duration* is: `(smh)`, e.g. 30s, 20m or 1h. The format for a *size* is: `(GMK)`, e.g. 1G, 200M or 4000k. diff --git a/server/server.yml b/server/server.yml index 6b2fc989..3e92f742 100644 --- a/server/server.yml +++ b/server/server.yml @@ -357,3 +357,9 @@ # log-level-overrides: # log-format: text # log-file: + +# Defines the size limit (in bytes) for a ntfy message. +# NOTE: FCM has size limit at 4000 bytes. APNS has size limit at 4KB. If you increase this size limit, FCM and APNS will NOT work for large messages. +# The default value is 4096 bytes. +# +# message-limit: