mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-05-19 11:53:26 +12:00
ff5c854192
- Use new notification request/opt-in flow for push - Implement unsubscribing - Implement muting - Implement emojis in title - Add iOS specific PWA warning - Don’t use websockets when web push is enabled - Fix duplicate notifications - Implement default web push setting - Implement changing subscription type - Implement web push subscription refresh - Implement web push notification click
40 lines
795 B
Go
40 lines
795 B
Go
//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: "web-push-keys",
|
|
Usage: "Generate web push VAPID keys",
|
|
UsageText: "ntfy web-push-keys",
|
|
Category: categoryServer,
|
|
Action: generateWebPushKeys,
|
|
}
|
|
|
|
func generateWebPushKeys(c *cli.Context) error {
|
|
privateKey, publicKey, err := webpush.GenerateVAPIDKeys()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintf(c.App.ErrWriter, `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)
|
|
|
|
return nil
|
|
}
|