mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fixing mobile notifications in Microsoft Teams
This commit is contained in:
@@ -41,10 +41,8 @@ func NewTeamsNotifier(model *m.AlertNotification) (alerting.Notifier, error) {
|
|||||||
|
|
||||||
type TeamsNotifier struct {
|
type TeamsNotifier struct {
|
||||||
NotifierBase
|
NotifierBase
|
||||||
Url string
|
Url string
|
||||||
Recipient string
|
log log.Logger
|
||||||
Mention string
|
|
||||||
log log.Logger
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TeamsNotifier) Notify(evalContext *alerting.EvalContext) error {
|
func (this *TeamsNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||||
@@ -75,17 +73,17 @@ func (this *TeamsNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
message := this.Mention
|
message := ""
|
||||||
if evalContext.Rule.State != m.AlertStateOK { //dont add message when going back to alert state ok.
|
if evalContext.Rule.State != m.AlertStateOK { //dont add message when going back to alert state ok.
|
||||||
message += " " + evalContext.Rule.Message
|
message = evalContext.Rule.Message
|
||||||
} else {
|
|
||||||
message += " " // summary must not be empty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"@type": "MessageCard",
|
"@type": "MessageCard",
|
||||||
"@context": "http://schema.org/extensions",
|
"@context": "http://schema.org/extensions",
|
||||||
"summary": message,
|
// summary MUST not be empty or the webhook request fails
|
||||||
|
// summary SHOULD contain some meaningful information, since it is used for mobile notifications
|
||||||
|
"summary": evalContext.GetNotificationTitle(),
|
||||||
"title": evalContext.GetNotificationTitle(),
|
"title": evalContext.GetNotificationTitle(),
|
||||||
"themeColor": evalContext.GetStateModel().Color,
|
"themeColor": evalContext.GetStateModel().Color,
|
||||||
"sections": []map[string]interface{}{
|
"sections": []map[string]interface{}{
|
||||||
|
|||||||
Reference in New Issue
Block a user