mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 19:23:31 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user