Add default message for Pushover notifications

If the message field is left empty for Pushover notifications, the API will return an error. This adds a default message if the message would otherwise be empty.

This fixes #8006.
This commit is contained in:
Alfred Krohmer
2017-12-11 21:51:46 +01:00
committed by Alfred Krohmer
parent 5d70a36ad8
commit 72e686457c

View File

@@ -129,6 +129,7 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error {
this.log.Error("Failed get rule link", "error", err)
return err
}
message := evalContext.Rule.Message
for idx, evt := range evalContext.EvalMatches {
message += fmt.Sprintf("\n<b>%s</b>: %v", evt.Metric, evt.Value)
@@ -142,6 +143,9 @@ func (this *PushoverNotifier) Notify(evalContext *alerting.EvalContext) error {
if evalContext.ImagePublicUrl != "" {
message += fmt.Sprintf("\n<a href=\"%s\">Show graph image</a>", evalContext.ImagePublicUrl)
}
if message == "" {
message = "Nothing to see here! (Set a notification message to replace this text.)"
}
q := url.Values{}
q.Add("user", this.UserKey)