From 67941865dba88d290f1cc43bd3f7f4e2ce44e2cb Mon Sep 17 00:00:00 2001 From: plantatorbob <114222940+plantatorbob@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:15:32 +0300 Subject: [PATCH] fix(alerting): correct success threshold for telegram (#551) Co-authored-by: dave --- alerting/provider/telegram/telegram.go | 2 +- alerting/provider/telegram/telegram_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/alerting/provider/telegram/telegram.go b/alerting/provider/telegram/telegram.go index a5edc12d..3a9d7ecb 100644 --- a/alerting/provider/telegram/telegram.go +++ b/alerting/provider/telegram/telegram.go @@ -69,7 +69,7 @@ type Body struct { func (provider *AlertProvider) buildRequestBody(endpoint *core.Endpoint, alert *alert.Alert, result *core.Result, resolved bool) []byte { var message, results string if resolved { - message = fmt.Sprintf("An alert for *%s* has been resolved:\n—\n _healthcheck passing successfully %d time(s) in a row_\n— ", endpoint.DisplayName(), alert.FailureThreshold) + message = fmt.Sprintf("An alert for *%s* has been resolved:\n—\n _healthcheck passing successfully %d time(s) in a row_\n— ", endpoint.DisplayName(), alert.SuccessThreshold) } else { message = fmt.Sprintf("An alert for *%s* has been triggered:\n—\n _healthcheck failed %d time(s) in a row_\n— ", endpoint.DisplayName(), alert.FailureThreshold) } diff --git a/alerting/provider/telegram/telegram_test.go b/alerting/provider/telegram/telegram_test.go index cde8fd30..fc93fda7 100644 --- a/alerting/provider/telegram/telegram_test.go +++ b/alerting/provider/telegram/telegram_test.go @@ -131,7 +131,7 @@ func TestAlertProvider_buildRequestBody(t *testing.T) { Provider: AlertProvider{ID: "123"}, Alert: alert.Alert{Description: &secondDescription, SuccessThreshold: 5, FailureThreshold: 3}, Resolved: true, - ExpectedBody: "{\"chat_id\":\"123\",\"text\":\"⛑ *Gatus* \\nAn alert for *endpoint-name* has been resolved:\\n—\\n _healthcheck passing successfully 3 time(s) in a row_\\n— \\n*Description* \\n_description-2_ \\n\\n*Condition results*\\n✅ - `[CONNECTED] == true`\\n✅ - `[STATUS] == 200`\\n\",\"parse_mode\":\"MARKDOWN\"}", + ExpectedBody: "{\"chat_id\":\"123\",\"text\":\"⛑ *Gatus* \\nAn alert for *endpoint-name* has been resolved:\\n—\\n _healthcheck passing successfully 5 time(s) in a row_\\n— \\n*Description* \\n_description-2_ \\n\\n*Condition results*\\n✅ - `[CONNECTED] == true`\\n✅ - `[STATUS] == 200`\\n\",\"parse_mode\":\"MARKDOWN\"}", }, } for _, scenario := range scenarios {