From 080563bd4f75cbf6f15a85b21a963dd3692d98b5 Mon Sep 17 00:00:00 2001 From: TwiN Date: Thu, 1 Dec 2022 20:19:11 -0500 Subject: [PATCH] fix(alerting): Improve ntfy alert --- alerting/provider/ntfy/ntfy.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/alerting/provider/ntfy/ntfy.go b/alerting/provider/ntfy/ntfy.go index b1e95907..e6d3ee59 100644 --- a/alerting/provider/ntfy/ntfy.go +++ b/alerting/provider/ntfy/ntfy.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "strconv" "github.com/TwiN/gatus/v4/alerting/alert" "github.com/TwiN/gatus/v4/client" @@ -69,19 +70,19 @@ type Body struct { // buildRequestBody builds the request body for the provider func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert *alert.Alert, result *core.Result, resolved bool) []byte { var message, tag string - if len(alert.GetDescription()) > 0 { - message = endpoint.DisplayName() + " - " + alert.GetDescription() - } else { - message = endpoint.DisplayName() - } if resolved { tag = "white_check_mark" + message = "An alert has been resolved after passing successfully " + strconv.Itoa(alert.SuccessThreshold) + " time(s) in a row" } else { tag = "x" + message = "An alert has been triggered due to having failed " + strconv.Itoa(alert.FailureThreshold) + " time(s) in a row" + } + if len(alert.GetDescription()) > 0 { + message += " with the following description: " + alert.GetDescription() } body, _ := json.Marshal(Body{ Topic: provider.Topic, - Title: "Gatus", + Title: "Gatus: " + endpoint.DisplayName(), Message: message, Tags: []string{tag}, Priority: provider.Priority,