feat(alerting): Add emoji to Threema alert notifications

This commit prepends emoji to Threema alert notifications to make it
easier to discern various notification types (e.g. alert, no data, ok).
This commit is contained in:
Danilo Bargen
2017-02-27 17:10:52 +01:00
parent 7d897c0980
commit 1422655e97

View File

@@ -126,9 +126,21 @@ func (notifier *ThreemaNotifier) Notify(evalContext *alerting.EvalContext) error
data.Set("to", notifier.RecipientID)
data.Set("secret", notifier.APISecret)
// Determine emoji
stateEmoji := ""
switch evalContext.Rule.State {
case m.AlertStateOK:
stateEmoji = "\u2705 " // White Heavy Check Mark
case m.AlertStateNoData:
stateEmoji = "\u2753 " // Black Question Mark Ornament
case m.AlertStateAlerting:
stateEmoji = "\u26A0 " // Warning sign
}
// Build message
message := fmt.Sprintf("%s\n\n*State:* %s\n*Message:* %s\n",
evalContext.GetNotificationTitle(), evalContext.Rule.Name, evalContext.Rule.Message)
message := fmt.Sprintf("%s%s\n\n*State:* %s\n*Message:* %s\n",
stateEmoji, evalContext.GetNotificationTitle(),
evalContext.Rule.Name, evalContext.Rule.Message)
ruleURL, err := evalContext.GetRuleUrl()
if err == nil {
message = message + fmt.Sprintf("*URL:* %s\n", ruleURL)