mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-07-20 10:04:08 +00:00
Add web push tests
This commit is contained in:
parent
ff5c854192
commit
a9fef387fa
20 changed files with 372 additions and 41 deletions
|
@ -14,11 +14,20 @@ func init() {
|
|||
}
|
||||
|
||||
var cmdWebPush = &cli.Command{
|
||||
Name: "web-push-keys",
|
||||
Usage: "Generate web push VAPID keys",
|
||||
UsageText: "ntfy web-push-keys",
|
||||
Name: "web-push",
|
||||
Usage: "Generate keys, in the future manage web push subscriptions",
|
||||
UsageText: "ntfy web-push [generate-keys]",
|
||||
Category: categoryServer,
|
||||
Action: generateWebPushKeys,
|
||||
|
||||
Subcommands: []*cli.Command{
|
||||
{
|
||||
Action: generateWebPushKeys,
|
||||
Name: "generate-keys",
|
||||
Usage: "Generate VAPID keys to enable browser background push notifications",
|
||||
UsageText: "ntfy web-push generate-keys",
|
||||
Category: categoryServer,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func generateWebPushKeys(c *cli.Context) error {
|
||||
|
@ -27,13 +36,28 @@ func generateWebPushKeys(c *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fmt.Fprintf(c.App.ErrWriter, `Add the following lines to your config file:
|
||||
fmt.Fprintf(c.App.ErrWriter, `Keys generated.
|
||||
|
||||
VAPID Public Key:
|
||||
%s
|
||||
|
||||
VAPID Private Key:
|
||||
%s
|
||||
|
||||
---
|
||||
|
||||
Add the following lines to your config file:
|
||||
|
||||
web-push-enabled: true
|
||||
web-push-public-key: %s
|
||||
web-push-private-key: %s
|
||||
web-push-subscriptions-file: <filename>
|
||||
web-push-email-address: <email address>
|
||||
`, publicKey, privateKey)
|
||||
|
||||
Look at the docs for other methods (e.g. command line flags & environment variables).
|
||||
|
||||
You will also need to set a base-url.
|
||||
`, publicKey, privateKey, publicKey, privateKey)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue