Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ — Add bigImageUrl option to push command #72

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func Push() cli.Command {
cli.StringFlag{Name: "url", Usage: "Override the Gotify URL"},
cli.BoolFlag{Name: "quiet,q", Usage: "Do not output anything (on success)"},
cli.StringFlag{Name: "contentType", Usage: "The content type of the message. See https://gotify.net/docs/msgextras#client-display"},
cli.StringFlag{Name: "clickUrl", Usage: "An URL to open upon clicking the notification. See https://gotify.net/docs/msgextras#client-notification"},
cli.StringFlag{Name: "clickUrl", Usage: "An URL to open upon clicking the notification. See https://gotify.net/docs/msgextras#clickurl"},
cli.StringFlag{Name: "bigImageUrl", Usage: "the URL of an image to display in the notification. See https://gotify.net/docs/msgextras#bigimageurl"},
cli.BoolFlag{Name: "disable-unescape-backslash", Usage: "Disable evaluating \\n and \\t (if set, \\n and \\t will be seen as a string)"},
},
Action: doPush,
Expand All @@ -50,6 +51,7 @@ func doPush(ctx *cli.Context) {
quiet := ctx.Bool("quiet")
contentType := ctx.String("contentType")
clickUrl := ctx.String("clickUrl")
bigImageUrl := ctx.String("bigImageUrl")

if token == "" {
if confErr != nil {
Expand Down Expand Up @@ -78,21 +80,23 @@ func doPush(ctx *cli.Context) {
Priority: priority,
}

msg.Extras = map[string]interface{}{
}
msg.Extras = map[string]interface{}{}

if contentType != "" {
msg.Extras["client::display"] = map[string]interface{}{
"contentType": contentType,
}
}

clientNotification := map[string]interface{}{}
if clickUrl != "" {
msg.Extras["client::notification"] = map[string]interface{}{
"click": map[string]string{
"url": clickUrl,
},
}
clientNotification["click"] = map[string]string{"url": clickUrl}
}
if bigImageUrl != "" {
clientNotification["bigImageUrl"] = bigImageUrl
}
if len(clientNotification) > 0 {
msg.Extras["client::notification"] = clientNotification
}

parsedURL, err := url.Parse(stringURL)
Expand Down
Loading