From 901bd4e29f5e962a36ba6cddf42b305ed45dac35 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sun, 14 Apr 2019 15:31:51 +0200 Subject: [PATCH] Add contentType property --- README.md | 1 + command/push.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 7156bca..4299951 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/command/push.go b/command/push.go index d0456c4..6d16403 100644 --- a/command/push.go +++ b/command/push.go @@ -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, } @@ -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'") @@ -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)