fix: allow saving email notification providers and render HTML body correctly

This commit is contained in:
GitHub Actions
2026-03-08 20:26:13 +00:00
parent d1baf6f1b0
commit d7de28a040
4 changed files with 4 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ func TestBlocker3_CreateProviderRejectsNonDiscordWithSecurityEvents(t *testing.T
{"webhook", "webhook", http.StatusCreated},
{"gotify", "gotify", http.StatusCreated},
{"slack", "slack", http.StatusBadRequest},
{"email", "email", http.StatusBadRequest},
{"email", "email", http.StatusCreated},
}
for _, tc := range testCases {

View File

@@ -38,7 +38,7 @@ func TestDiscordOnly_CreateRejectsNonDiscord(t *testing.T) {
{"slack", "slack", http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE"},
{"telegram", "telegram", http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE"},
{"generic", "generic", http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE"},
{"email", "email", http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE"},
{"email", "email", http.StatusCreated, ""},
}
for _, tc := range testCases {

View File

@@ -168,7 +168,7 @@ func (h *NotificationProviderHandler) Create(c *gin.Context) {
}
providerType := strings.ToLower(strings.TrimSpace(req.Type))
if providerType != "discord" && providerType != "gotify" && providerType != "webhook" {
if providerType != "discord" && providerType != "gotify" && providerType != "webhook" && providerType != "email" {
respondSanitizedProviderError(c, http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE", "validation", "Unsupported notification provider type")
return
}
@@ -228,7 +228,7 @@ func (h *NotificationProviderHandler) Update(c *gin.Context) {
}
providerType := strings.ToLower(strings.TrimSpace(existing.Type))
if providerType != "discord" && providerType != "gotify" && providerType != "webhook" {
if providerType != "discord" && providerType != "gotify" && providerType != "webhook" && providerType != "email" {
respondSanitizedProviderError(c, http.StatusBadRequest, "UNSUPPORTED_PROVIDER_TYPE", "validation", "Unsupported notification provider type")
return
}

View File

@@ -393,7 +393,6 @@ func (s *MailService) SendEmail(ctx context.Context, to []string, subject, htmlB
auth = smtp.PlainAuth("", config.Username, config.Password, config.Host)
}
htmlBody = sanitizeAndNormalizeHTMLBody(htmlBody)
htmlBody = sanitizeEmailContent(htmlBody)
for _, recipient := range to {