Compare commits

...

1 Commits

Author SHA1 Message Date
538673281e
Added some debugging
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
2021-12-05 15:16:53 +00:00

View File

@ -12,9 +12,12 @@ import (
func HandleAlertmanagerPayloadPost(c *fiber.Ctx) error {
payload := template.Data{}
if err := c.BodyParser(&payload); err != nil {
fmt.Println("Failed to parse payload", err)
return err
}
fmt.Println("Got alertmanager payload")
for _, alert := range payload.Alerts {
message := ""
if alert.Status == "firing" {
@ -30,6 +33,7 @@ func HandleAlertmanagerPayloadPost(c *fiber.Ctx) error {
_, err := matrixClient.SendText(id.RoomID(*defaultRoom), message)
if err != nil {
fmt.Println("Failed sending to Matrix", err)
if httpErr, ok := err.(mautrix.HTTPError); ok {
return c.Status(httpErr.Response.StatusCode).SendString(httpErr.RespError.Err)
}