Commit 1422655e by Danilo Bargen

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).
parent 7d897c09
...@@ -126,9 +126,21 @@ func (notifier *ThreemaNotifier) Notify(evalContext *alerting.EvalContext) error ...@@ -126,9 +126,21 @@ func (notifier *ThreemaNotifier) Notify(evalContext *alerting.EvalContext) error
data.Set("to", notifier.RecipientID) data.Set("to", notifier.RecipientID)
data.Set("secret", notifier.APISecret) 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 // Build message
message := fmt.Sprintf("%s\n\n*State:* %s\n*Message:* %s\n", message := fmt.Sprintf("%s%s\n\n*State:* %s\n*Message:* %s\n",
evalContext.GetNotificationTitle(), evalContext.Rule.Name, evalContext.Rule.Message) stateEmoji, evalContext.GetNotificationTitle(),
evalContext.Rule.Name, evalContext.Rule.Message)
ruleURL, err := evalContext.GetRuleUrl() ruleURL, err := evalContext.GetRuleUrl()
if err == nil { if err == nil {
message = message + fmt.Sprintf("*URL:* %s\n", ruleURL) message = message + fmt.Sprintf("*URL:* %s\n", ruleURL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment