From 88c6b4adae5bc53710dc59721e82242f983011fb Mon Sep 17 00:00:00 2001 From: binwiederhier Date: Sat, 17 Jun 2023 21:57:47 -0400 Subject: [PATCH] Rename web-push-subscriptions-file to web-push-file --- cmd/serve.go | 10 +++++----- cmd/webpush.go | 2 +- docs/config.md | 11 +++++------ docs/develop.md | 2 +- server/config.go | 4 ++-- server/server.go | 2 +- server/server.yml | 4 ++-- server/server_test.go | 2 +- 8 files changed, 18 insertions(+), 19 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index 6d1b111a..62494ffb 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -96,7 +96,7 @@ var flagsServe = append( altsrc.NewStringFlag(&cli.StringFlag{Name: "profile-listen-http", Aliases: []string{"profile_listen_http"}, EnvVars: []string{"NTFY_PROFILE_LISTEN_HTTP"}, Usage: "ip:port used to expose the profiling endpoints (implicitly enables profiling)"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-public-key", Aliases: []string{"web_push_public_key"}, EnvVars: []string{"NTFY_WEB_PUSH_PUBLIC_KEY"}, Usage: "public key used for web push notifications"}), altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-private-key", Aliases: []string{"web_push_private_key"}, EnvVars: []string{"NTFY_WEB_PUSH_PRIVATE_KEY"}, Usage: "private key used for web push notifications"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "web-push-subscriptions-file", Aliases: []string{"web_push_subscriptions_file"}, EnvVars: []string{"NTFY_WEB_PUSH_SUBSCRIPTIONS_FILE"}, Usage: "file used to store web push subscriptions"}), + 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"}), ) @@ -135,7 +135,7 @@ func execServe(c *cli.Context) error { firebaseKeyFile := c.String("firebase-key-file") webPushPrivateKey := c.String("web-push-private-key") webPushPublicKey := c.String("web-push-public-key") - webPushSubscriptionsFile := c.String("web-push-subscriptions-file") + webPushFile := c.String("web-push-file") webPushEmailAddress := c.String("web-push-email-address") cacheFile := c.String("cache-file") cacheDuration := c.Duration("cache-duration") @@ -191,8 +191,8 @@ func execServe(c *cli.Context) error { // Check values if firebaseKeyFile != "" && !util.FileExists(firebaseKeyFile) { return errors.New("if set, FCM key file must exist") - } else if webPushPublicKey != "" && (webPushPrivateKey == "" || webPushSubscriptionsFile == "" || webPushEmailAddress == "" || baseURL == "") { - return errors.New("if web push is enabled, web-push-private-key, web-push-public-key, web-push-subscriptions-file, web-push-email-address, and base-url should be set. run 'ntfy web-push generate-keys' to generate keys") + } else if webPushPublicKey != "" && (webPushPrivateKey == "" || webPushFile == "" || webPushEmailAddress == "" || baseURL == "") { + return errors.New("if web push is enabled, web-push-private-key, web-push-public-key, web-push-file, web-push-email-address, and base-url should be set. run 'ntfy web-push generate-keys' to generate keys") } else if keepaliveInterval < 5*time.Second { return errors.New("keepalive interval cannot be lower than five seconds") } else if managerInterval < 5*time.Second { @@ -359,7 +359,7 @@ func execServe(c *cli.Context) error { conf.Version = c.App.Version conf.WebPushPrivateKey = webPushPrivateKey conf.WebPushPublicKey = webPushPublicKey - conf.WebPushSubscriptionsFile = webPushSubscriptionsFile + conf.WebPushFile = webPushFile conf.WebPushEmailAddress = webPushEmailAddress // Set up hot-reloading of config diff --git a/cmd/webpush.go b/cmd/webpush.go index 6e74def2..ec66f083 100644 --- a/cmd/webpush.go +++ b/cmd/webpush.go @@ -39,7 +39,7 @@ func generateWebPushKeys(c *cli.Context) error { web-push-public-key: %s web-push-private-key: %s -web-push-subscriptions-file: /var/cache/ntfy/webpush.db # or similar +web-push-file: /var/cache/ntfy/webpush.db # or similar web-push-email-address: See https://ntfy.sh/docs/config/#web-push for details. diff --git a/docs/config.md b/docs/config.md index 8aaff790..70c860c1 100644 --- a/docs/config.md +++ b/docs/config.md @@ -801,7 +801,7 @@ a database to keep track of the browser's subscriptions, and an admin email addr - `web-push-public-key` is the generated VAPID public key, e.g. AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890 - `web-push-private-key` is the generated VAPID private key, e.g. AA2BB1234567890abcdefzxcvbnm1234567890 -- `web-push-subscriptions-file` is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db` +- `web-push-file` is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db` - `web-push-email-address` is the admin email address send to the push provider, e.g. `sysadmin@example.com` Limitations: @@ -825,11 +825,11 @@ Then copy the generated values into your `server.yml` or use the corresponding e ```yaml web-push-public-key: AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890 web-push-private-key: AA2BB1234567890abcdefzxcvbnm1234567890 -web-push-subscriptions-file: /var/cache/ntfy/webpush.db +web-push-file: /var/cache/ntfy/webpush.db web-push-email-address: sysadmin@example.com ``` -The `web-push-subscriptions-file` is used to store the push subscriptions. Unused subscriptions will send out a warning after 7 days, +The `web-push-file` is used to store the push subscriptions. Unused subscriptions will send out a warning after 7 days, and will automatically expire after 9 days (not configurable). If the gateway returns an error (e.g. 410 Gone when a user has unsubscribed), subscriptions are also removed automatically. @@ -1337,7 +1337,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`). | `billing-contact` | `NTFY_BILLING_CONTACT` | *email address* or *website* | - | Payments: Email or website displayed in Upgrade dialog as a billing contact | | `web-push-public-key` | `NTFY_WEB_PUSH_PUBLIC_KEY` | *string* | - | Web Push: Public Key. Run `ntfy webpush keys` to generate | | `web-push-private-key` | `NTFY_WEB_PUSH_PRIVATE_KEY` | *string* | - | Web Push: Private Key. Run `ntfy webpush keys` to generate | -| `web-push-subscriptions-file` | `NTFY_WEB_PUSH_SUBSCRIPTIONS_FILE` | *string* | - | Web Push: Subscriptions file | +| `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 | The format for a *duration* is: `(smh)`, e.g. 30s, 20m or 1h. @@ -1433,8 +1433,7 @@ OPTIONS: --profile-listen-http value, --profile_listen_http value ip:port used to expose the profiling endpoints (implicitly enables profiling) [$NTFY_PROFILE_LISTEN_HTTP] --web-push-public-key value, --web_push_public_key value public key used for web push notifications [$NTFY_WEB_PUSH_PUBLIC_KEY] --web-push-private-key value, --web_push_private_key value private key used for web push notifications [$NTFY_WEB_PUSH_PRIVATE_KEY] - --web-push-subscriptions-file value, --web_push_subscriptions_file value file used to store web push subscriptions [$NTFY_WEB_PUSH_SUBSCRIPTIONS_FILE] + --web-push-file value, --web_push_file value file used to store web push subscriptions [$NTFY_WEB_PUSH_FILE] --web-push-email-address value, --web_push_email_address value e-mail address of sender, required to use browser push services [$NTFY_WEB_PUSH_EMAIL_ADDRESS] --help, -h show help - ``` diff --git a/docs/develop.md b/docs/develop.md index be6795f6..ede9f917 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -258,7 +258,7 @@ Reference: