Skip to content

Commit

Permalink
Add contentType property
Browse files Browse the repository at this point in the history
  • Loading branch information
jmattheis committed Apr 14, 2019
1 parent a9d5ea9 commit 901bd4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ OPTIONS:
--token value Override the app token
--url value Override the Gotify URL
--quiet, -q Do not output anything (on success)
--contentType value The content type of the message. See https://gotify.net/docs/msgextras#client-display
```

## Configuration
Expand Down
10 changes: 10 additions & 0 deletions command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func Push() cli.Command {
cli.StringFlag{Name: "token", Usage: "Override the app token"},
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"},
},
Action: doPush,
}
Expand All @@ -43,6 +44,7 @@ func doPush(ctx *cli.Context) {
title := ctx.String("title")
token := ctx.String("token")
quiet := ctx.Bool("quiet")
contentType := ctx.String("contentType")
if token == "" {
if confErr != nil {
utils.Exit1With("token is not configured, run 'gotify init'")
Expand All @@ -65,6 +67,14 @@ func doPush(ctx *cli.Context) {
Priority: priority,
}

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

parsedURL, err := url.Parse(stringURL)
if err != nil {
utils.Exit1With("invalid url", stringURL)
Expand Down

0 comments on commit 901bd4e

Please sign in to comment.