Skip to content

Commit c8bb424

Browse files
authored
Add --clickUrl support
1 parent 3c2ba25 commit c8bb424

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

command/push.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func Push() cli.Command {
2929
cli.StringFlag{Name: "url", Usage: "Override the Gotify URL"},
3030
cli.BoolFlag{Name: "quiet,q", Usage: "Do not output anything (on success)"},
3131
cli.StringFlag{Name: "contentType", Usage: "The content type of the message. See https://gotify.net/docs/msgextras#client-display"},
32+
cli.StringFlag{Name: "clickUrl", Usage: "An URL to open upon clicking the notification. See https://gotify.net/docs/msgextras#client-notification"},
3233
cli.BoolFlag{Name: "disable-unescape-backslash", Usage: "Disable evaluating \\n and \\t (if set, \\n and \\t will be seen as a string)"},
3334
},
3435
Action: doPush,
@@ -48,13 +49,16 @@ func doPush(ctx *cli.Context) {
4849
token := ctx.String("token")
4950
quiet := ctx.Bool("quiet")
5051
contentType := ctx.String("contentType")
52+
clickUrl := ctx.String("clickUrl")
53+
5154
if token == "" {
5255
if confErr != nil {
5356
utils.Exit1With("token is not configured, run 'gotify init'")
5457
return
5558
}
5659
token = conf.Token
5760
}
61+
5862
stringURL := ctx.String("url")
5963
if stringURL == "" {
6064
if confErr != nil {
@@ -74,10 +78,19 @@ func doPush(ctx *cli.Context) {
7478
Priority: priority,
7579
}
7680

81+
msg.Extras = map[string]interface{}{
82+
}
83+
7784
if contentType != "" {
78-
msg.Extras = map[string]interface{}{
79-
"client::display": map[string]interface{}{
80-
"contentType": contentType,
85+
msg.Extras["client::display"] = map[string]interface{}{
86+
"contentType": contentType,
87+
}
88+
}
89+
90+
if clickUrl != "" {
91+
msg.Extras["client::notification"] = map[string]interface{}{
92+
"click": map[string]string{
93+
"url": clickUrl,
8194
},
8295
}
8396
}

0 commit comments

Comments
 (0)