fix(webhook): log errors in webhook response
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kolaente 2024-06-03 13:11:37 +02:00
parent 73780e4b50
commit a6fccfb908
Signed by: konrad
GPG Key ID: F40E70337AB24C9B

View File

@ -24,6 +24,7 @@ import (
"encoding/base64"
"encoding/hex"
"encoding/json"
"io"
"net/http"
"net/url"
"sort"
@ -294,6 +295,16 @@ func (w *Webhook) sendWebhookPayload(p *WebhookPayload) (err error) {
}
defer res.Body.Close()
if res.StatusCode > 399 {
responseBody, err := io.ReadAll(res.Body)
if err != nil {
return err
}
log.Errorf("Got response with status %d from webhook %d: %s", res.StatusCode, w.ID, responseBody)
}
log.Debugf("Sent webhook payload for webhook %d for event %s", w.ID, p.EventName)
return
}