commit 8bad08a52304a12ea5374182f13b83b6286e378d from: Oliver Lowe date: Tue Jun 15 06:44:12 2021 UTC Set notification priority if passed in commit - d5a4fb2806bc51b5b41bc2a13003c55d6e77461f commit + 8bad08a52304a12ea5374182f13b83b6286e378d blob - 41119f9322acb87af84f93940a73f20f78e98dc2 blob + 55b2b71a0bca811b47b52a81aeca95f42e468f1a --- pushover.go +++ pushover.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http" "net/url" + "strconv" "strings" ) @@ -12,6 +13,13 @@ const apiurl = "https://api.pushover.net/1/messages.js const MaxMsgLength = 1024 const MaxTitleLength = 250 +const ( + PriorityLowest = -2 + iota + PriorityLow + PriorityNormal + PriorityHigh +) + // Message represents a message in the Pushover Message API. type Message struct { User string @@ -55,6 +63,9 @@ func Push(m Message) error { req.Add("user", m.User) req.Add("title", m.Title) req.Add("message", m.Message) + if m.Priority != 0 { + req.Add("priority", strconv.Itoa(m.Priority)) + } resp, err := http.PostForm(apiurl, req) if err != nil { return err