Updated formatting for discord messages
Container image / image (push) Successful in 1m45s

This commit is contained in:
2026-05-15 06:55:43 +00:00
parent a11b31f160
commit 8638ab5432
+9 -1
View File
@@ -25,12 +25,20 @@ type discordPayload struct {
} }
// sendDiscord posts msg.Subject + body to the configured webhook URL. // sendDiscord posts msg.Subject + body to the configured webhook URL.
// When the alert has a custom BodyTemplate, the rendered body is shipped
// verbatim — the operator has opted out of the default subject header
// and code-block wrapping in favour of their own formatting.
func sendDiscord(a *config.Alert, msg Message) error { func sendDiscord(a *config.Alert, msg Message) error {
if a.DiscordWebhook == "" { if a.DiscordWebhook == "" {
return errors.New("discord webhook url not set") return errors.New("discord webhook url not set")
} }
content := msg.Subject + "\n```\n" + msg.Body + "\n```" var content string
if a.BodyTemplate != "" {
content = msg.Body
} else {
content = msg.Subject + "\n```\n" + msg.Body + "\n```"
}
raw, err := json.Marshal(discordPayload{Content: content}) raw, err := json.Marshal(discordPayload{Content: content})
if err != nil { if err != nil {
return err return err