Skip to content

Commit 7d0b8ce

Browse files
ldidryjmattheis
andauthored
feat: add bigImageUrl option to push command (#72)
Co-authored-by: Jannis Mattheis <contact@jmattheis.de>
1 parent 1998489 commit 7d0b8ce

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

command/push.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ 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"},
32+
cli.StringFlag{Name: "clickUrl", Usage: "An URL to open upon clicking the notification. See https://gotify.net/docs/msgextras#clickurl"},
33+
cli.StringFlag{Name: "bigImageUrl", Usage: "the URL of an image to display in the notification. See https://gotify.net/docs/msgextras#bigimageurl"},
3334
cli.BoolFlag{Name: "disable-unescape-backslash", Usage: "Disable evaluating \\n and \\t (if set, \\n and \\t will be seen as a string)"},
3435
},
3536
Action: doPush,
@@ -50,6 +51,7 @@ func doPush(ctx *cli.Context) {
5051
quiet := ctx.Bool("quiet")
5152
contentType := ctx.String("contentType")
5253
clickUrl := ctx.String("clickUrl")
54+
bigImageUrl := ctx.String("bigImageUrl")
5355

5456
if token == "" {
5557
if confErr != nil {
@@ -78,21 +80,23 @@ func doPush(ctx *cli.Context) {
7880
Priority: priority,
7981
}
8082

81-
msg.Extras = map[string]interface{}{
82-
}
83+
msg.Extras = map[string]interface{}{}
8384

8485
if contentType != "" {
8586
msg.Extras["client::display"] = map[string]interface{}{
8687
"contentType": contentType,
8788
}
8889
}
8990

91+
clientNotification := map[string]interface{}{}
9092
if clickUrl != "" {
91-
msg.Extras["client::notification"] = map[string]interface{}{
92-
"click": map[string]string{
93-
"url": clickUrl,
94-
},
95-
}
93+
clientNotification["click"] = map[string]string{"url": clickUrl}
94+
}
95+
if bigImageUrl != "" {
96+
clientNotification["bigImageUrl"] = bigImageUrl
97+
}
98+
if len(clientNotification) > 0 {
99+
msg.Extras["client::notification"] = clientNotification
96100
}
97101

98102
parsedURL, err := url.Parse(stringURL)

0 commit comments

Comments
 (0)