fix: properly report HTTP errors in webhook tests

- Webhook test was showing success even when receiving 400/500 errors
- Now correctly reports HTTP status errors to the UI
- Added debug logging for Gotify webhooks to help troubleshooting
- Addresses #342 where Gotify webhooks appeared to work but didn't
This commit is contained in:
Pulse Monitor
2025-08-23 07:33:14 +00:00
parent c03f505584
commit 8febd23f48
2 changed files with 9 additions and 3 deletions
+5
View File
@@ -427,6 +427,11 @@ func (h *NotificationHandlers) TestWebhook(w http.ResponseWriter, r *http.Reques
if err != nil {
result["error"] = err.Error()
w.WriteHeader(http.StatusBadRequest)
} else if status < 200 || status >= 300 {
// HTTP error from webhook endpoint
result["error"] = fmt.Sprintf("Webhook returned HTTP %d: %s", status, response)
result["success"] = false
w.WriteHeader(http.StatusBadRequest)
} else {
result["success"] = true
}
+4 -3
View File
@@ -622,13 +622,14 @@ func (n *NotificationManager) sendWebhookRequest(webhook WebhookConfig, jsonData
req.Header.Set(key, value)
}
// Debug log the payload for Telegram webhooks
if webhook.Service == "telegram" {
// Debug log the payload for Telegram and Gotify webhooks
if webhook.Service == "telegram" || webhook.Service == "gotify" {
log.Debug().
Str("webhook", webhook.Name).
Str("service", webhook.Service).
Str("url", webhookURL).
Str("payload", string(jsonData)).
Msg("Sending Telegram webhook")
Msg("Sending webhook with payload")
}
// Send request