Skip to content

Commit

Permalink
Merge pull request #3637 from uselagoon/empty-notifications
Browse files Browse the repository at this point in the history
fix: return error when no matching event to prevent empty email notifications
  • Loading branch information
shreddedbacon authored Jan 11, 2024
2 parents 92af324 + 56f75a7 commit 63b8d2b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions services/logs2notifications/internal/handler/email_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
if err != nil {
eventSplit := strings.Split(notification.Event, ":")
if eventSplit[0] != "problem" {
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}
if eventSplit[1] == "insert" {
tpl = "problemNotification"
Expand Down Expand Up @@ -127,7 +127,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
case "problemNotification":
eventSplit := strings.Split(notification.Event, ":")
if eventSplit[0] != "problem" && eventSplit[1] == "insert" {
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}
mainHTMLTpl = `[{{.ProjectName}}] New problem found for <code>{{.EnvironmentName}}</code>
<ul><li>* Service: {{.ServiceName}}</li>{{ if ne .Severity "" }}
Expand All @@ -142,7 +142,7 @@ func (h *Messaging) processEmailTemplates(notification *Notification) (string, s
notification.Meta.EnvironmentName,
)
default:
return "", "", "", "", "", nil
return "", "", "", "", "", fmt.Errorf("no matching event")
}

var body bytes.Buffer
Expand Down

0 comments on commit 63b8d2b

Please sign in to comment.