Commit 2661054f by Hugo Häggmark Committed by GitHub

Hangouts: fixes notifications for alerts with empty message (#23559)

* Hangouts: fixes notifications for alerts with empty message

* Update pkg/services/alerting/notifiers/googlechat.go

Co-Authored-By: Marcus Efraimsson <marcus.efraimsson@gmail.com>

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
parent aaab636b
...@@ -126,13 +126,15 @@ func (gcn *GoogleChatNotifier) Notify(evalContext *alerting.EvalContext) error { ...@@ -126,13 +126,15 @@ func (gcn *GoogleChatNotifier) Notify(evalContext *alerting.EvalContext) error {
gcn.log.Error("evalContext returned an invalid rule URL") gcn.log.Error("evalContext returned an invalid rule URL")
} }
// add a text paragraph widget for the message widgets := []widget{}
widgets := []widget{ if len(evalContext.Rule.Message) > 0 {
textParagraphWidget{ // add a text paragraph widget for the message if there is a message
// Google Chat API doesn't accept an empty text property
widgets = append(widgets, textParagraphWidget{
Text: text{ Text: text{
Text: evalContext.Rule.Message, Text: evalContext.Rule.Message,
}, },
}, })
} }
// add a text paragraph widget for the fields // add a text paragraph widget for the fields
......
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