1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-12 15:43:23 +02:00

Docs in server.yml, schemaVersion table, refactoring

This commit is contained in:
binwiederhier 2023-06-08 21:45:52 -04:00
parent d3ac976d05
commit 9d38aeb863
7 changed files with 74 additions and 37 deletions

50
cmd/webpush.go Normal file
View file

@ -0,0 +1,50 @@
//go:build !noserver
package cmd
import (
"fmt"
"github.com/SherClockHolmes/webpush-go"
"github.com/urfave/cli/v2"
)
func init() {
commands = append(commands, cmdWebPush)
}
var cmdWebPush = &cli.Command{
Name: "webpush",
Usage: "Generate keys, in the future manage web push subscriptions",
UsageText: "ntfy web-push [generate-keys]",
Category: categoryServer,
Subcommands: []*cli.Command{
{
Action: generateWebPushKeys,
Name: "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 {
privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
if err != nil {
return err
}
fmt.Fprintf(c.App.ErrWriter, `Web Push keys generated. Add the following lines to your config file:
web-push-public-key: %s
web-push-private-key: %s
web-push-subscriptions-file: /var/cache/ntfy/webpush.db # or similar
web-push-email-address: <email address>
See https://ntfy.sh/docs/config/#web-push for details.
`, publicKey, privateKey)
return nil
}