Skip to content

Commit

Permalink
Add check for SES bounce notif type (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haseeb Ahmad committed Jan 28, 2023
1 parent 8985e5c commit 755344e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/bounce/webhooks/ses.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type sesNotif struct {
type sesTimestamp time.Time

type sesMail struct {
EventType string `json:"eventType"`
NotifType string `json:"notificationType"`
Bounce struct {
BounceType string `json:"bounceType"`
Expand Down Expand Up @@ -118,6 +119,10 @@ func (s *SES) ProcessBounce(b []byte) (models.Bounce, error) {
return bounce, fmt.Errorf("error unmarshalling SES notification: %v", err)
}

if !(m.EventType == "Bounce" || m.NotifType == "Bounce") {
return bounce, errors.New("notification type is not bounce")
}

if len(m.Mail.Destination) == 0 {
return bounce, errors.New("no destination e-mails found in SES notification")
}
Expand Down

0 comments on commit 755344e

Please sign in to comment.