Skip to content

Commit 88c6b4a

Browse files
committed
Rename web-push-subscriptions-file to web-push-file
1 parent 020996e commit 88c6b4a

File tree

8 files changed

+18
-19
lines changed

8 files changed

+18
-19
lines changed

cmd/serve.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var flagsServe = append(
9696
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)"}),
9797
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"}),
9898
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"}),
99-
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"}),
99+
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"}),
100100
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"}),
101101
)
102102

@@ -135,7 +135,7 @@ func execServe(c *cli.Context) error {
135135
firebaseKeyFile := c.String("firebase-key-file")
136136
webPushPrivateKey := c.String("web-push-private-key")
137137
webPushPublicKey := c.String("web-push-public-key")
138-
webPushSubscriptionsFile := c.String("web-push-subscriptions-file")
138+
webPushFile := c.String("web-push-file")
139139
webPushEmailAddress := c.String("web-push-email-address")
140140
cacheFile := c.String("cache-file")
141141
cacheDuration := c.Duration("cache-duration")
@@ -191,8 +191,8 @@ func execServe(c *cli.Context) error {
191191
// Check values
192192
if firebaseKeyFile != "" && !util.FileExists(firebaseKeyFile) {
193193
return errors.New("if set, FCM key file must exist")
194-
} else if webPushPublicKey != "" && (webPushPrivateKey == "" || webPushSubscriptionsFile == "" || webPushEmailAddress == "" || baseURL == "") {
195-
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")
194+
} else if webPushPublicKey != "" && (webPushPrivateKey == "" || webPushFile == "" || webPushEmailAddress == "" || baseURL == "") {
195+
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")
196196
} else if keepaliveInterval < 5*time.Second {
197197
return errors.New("keepalive interval cannot be lower than five seconds")
198198
} else if managerInterval < 5*time.Second {
@@ -359,7 +359,7 @@ func execServe(c *cli.Context) error {
359359
conf.Version = c.App.Version
360360
conf.WebPushPrivateKey = webPushPrivateKey
361361
conf.WebPushPublicKey = webPushPublicKey
362-
conf.WebPushSubscriptionsFile = webPushSubscriptionsFile
362+
conf.WebPushFile = webPushFile
363363
conf.WebPushEmailAddress = webPushEmailAddress
364364

365365
// Set up hot-reloading of config

cmd/webpush.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func generateWebPushKeys(c *cli.Context) error {
3939
4040
web-push-public-key: %s
4141
web-push-private-key: %s
42-
web-push-subscriptions-file: /var/cache/ntfy/webpush.db # or similar
42+
web-push-file: /var/cache/ntfy/webpush.db # or similar
4343
web-push-email-address: <email address>
4444
4545
See https://ntfy.sh/docs/config/#web-push for details.

docs/config.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ a database to keep track of the browser's subscriptions, and an admin email addr
801801

802802
- `web-push-public-key` is the generated VAPID public key, e.g. AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890
803803
- `web-push-private-key` is the generated VAPID private key, e.g. AA2BB1234567890abcdefzxcvbnm1234567890
804-
- `web-push-subscriptions-file` is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db`
804+
- `web-push-file` is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db`
805805
- `web-push-email-address` is the admin email address send to the push provider, e.g. `sysadmin@example.com`
806806

807807
Limitations:
@@ -825,11 +825,11 @@ Then copy the generated values into your `server.yml` or use the corresponding e
825825
```yaml
826826
web-push-public-key: AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890
827827
web-push-private-key: AA2BB1234567890abcdefzxcvbnm1234567890
828-
web-push-subscriptions-file: /var/cache/ntfy/webpush.db
828+
web-push-file: /var/cache/ntfy/webpush.db
829829
web-push-email-address: sysadmin@example.com
830830
```
831831

832-
The `web-push-subscriptions-file` is used to store the push subscriptions. Unused subscriptions will send out a warning after 7 days,
832+
The `web-push-file` is used to store the push subscriptions. Unused subscriptions will send out a warning after 7 days,
833833
and will automatically expire after 9 days (not configurable). If the gateway returns an error (e.g. 410 Gone when a user has unsubscribed),
834834
subscriptions are also removed automatically.
835835

@@ -1337,7 +1337,7 @@ variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`).
13371337
| `billing-contact` | `NTFY_BILLING_CONTACT` | *email address* or *website* | - | Payments: Email or website displayed in Upgrade dialog as a billing contact |
13381338
| `web-push-public-key` | `NTFY_WEB_PUSH_PUBLIC_KEY` | *string* | - | Web Push: Public Key. Run `ntfy webpush keys` to generate |
13391339
| `web-push-private-key` | `NTFY_WEB_PUSH_PRIVATE_KEY` | *string* | - | Web Push: Private Key. Run `ntfy webpush keys` to generate |
1340-
| `web-push-subscriptions-file` | `NTFY_WEB_PUSH_SUBSCRIPTIONS_FILE` | *string* | - | Web Push: Subscriptions file |
1340+
| `web-push-file` | `NTFY_WEB_PUSH_FILE` | *string* | - | Web Push: Database file that stores subscriptions |
13411341
| `web-push-email-address` | `NTFY_WEB_PUSH_EMAIL_ADDRESS` | *string* | - | Web Push: Sender email address |
13421342

13431343
The format for a *duration* is: `<number>(smh)`, e.g. 30s, 20m or 1h.
@@ -1433,8 +1433,7 @@ OPTIONS:
14331433
--profile-listen-http value, --profile_listen_http value ip:port used to expose the profiling endpoints (implicitly enables profiling) [$NTFY_PROFILE_LISTEN_HTTP]
14341434
--web-push-public-key value, --web_push_public_key value public key used for web push notifications [$NTFY_WEB_PUSH_PUBLIC_KEY]
14351435
--web-push-private-key value, --web_push_private_key value private key used for web push notifications [$NTFY_WEB_PUSH_PRIVATE_KEY]
1436-
--web-push-subscriptions-file value, --web_push_subscriptions_file value file used to store web push subscriptions [$NTFY_WEB_PUSH_SUBSCRIPTIONS_FILE]
1436+
--web-push-file value, --web_push_file value file used to store web push subscriptions [$NTFY_WEB_PUSH_FILE]
14371437
--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]
14381438
--help, -h show help
1439-
14401439
```

docs/develop.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ Reference: <https://stackoverflow.com/questions/34160509/options-for-testing-ser
258258
--web-push-enabled \
259259
--web-push-public-key KEY \
260260
--web-push-private-key KEY \
261-
--web-push-subscriptions-file=/tmp/subscriptions.db
261+
--web-push-file=/tmp/webpush.db
262262
```
263263

264264
3. In `web/public/config.js`:

server/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ type Config struct {
155155
Version string // injected by App
156156
WebPushPrivateKey string
157157
WebPushPublicKey string
158-
WebPushSubscriptionsFile string
158+
WebPushFile string
159159
WebPushEmailAddress string
160160
WebPushExpiryDuration time.Duration
161161
WebPushExpiryWarningDuration time.Duration
@@ -242,7 +242,7 @@ func NewConfig() *Config {
242242
Version: "",
243243
WebPushPrivateKey: "",
244244
WebPushPublicKey: "",
245-
WebPushSubscriptionsFile: "",
245+
WebPushFile: "",
246246
WebPushEmailAddress: "",
247247
WebPushExpiryDuration: DefaultWebPushExpiryDuration,
248248
WebPushExpiryWarningDuration: DefaultWebPushExpiryWarningDuration,

server/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func New(conf *Config) (*Server, error) {
158158
}
159159
var webPush *webPushStore
160160
if conf.WebPushPublicKey != "" {
161-
webPush, err = newWebPushStore(conf.WebPushSubscriptionsFile)
161+
webPush, err = newWebPushStore(conf.WebPushFile)
162162
if err != nil {
163163
return nil, err
164164
}

server/server.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,12 @@
155155
#
156156
# - web-push-public-key is the generated VAPID public key, e.g. AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890
157157
# - web-push-private-key is the generated VAPID private key, e.g. AA2BB1234567890abcdefzxcvbnm1234567890
158-
# - web-push-subscriptions-file is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db`
158+
# - web-push-file is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db`
159159
# - web-push-email-address is the admin email address send to the push provider, e.g. `sysadmin@example.com`
160160
#
161161
# web-push-public-key:
162162
# web-push-private-key:
163-
# web-push-subscriptions-file:
163+
# web-push-file:
164164
# web-push-email-address:
165165

166166
# If enabled, ntfy can perform voice calls via Twilio via the "X-Call" header.

server/server_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,7 @@ func newTestConfigWithWebPush(t *testing.T) *Config {
26222622
conf := newTestConfig(t)
26232623
privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
26242624
require.Nil(t, err)
2625-
conf.WebPushSubscriptionsFile = filepath.Join(t.TempDir(), "webpush.db")
2625+
conf.WebPushFile = filepath.Join(t.TempDir(), "webpush.db")
26262626
conf.WebPushEmailAddress = "testing@example.com"
26272627
conf.WebPushPrivateKey = privateKey
26282628
conf.WebPushPublicKey = publicKey

0 commit comments

Comments
 (0)