From 755344e74b85fb4dc7e803d15ebc5f60ee839cd9 Mon Sep 17 00:00:00 2001 From: Haseeb Ahmad Date: Sat, 28 Jan 2023 03:25:48 -0500 Subject: [PATCH] Add check for SES bounce notif type (#1123) --- internal/bounce/webhooks/ses.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/bounce/webhooks/ses.go b/internal/bounce/webhooks/ses.go index 8ad252c..02b423c 100644 --- a/internal/bounce/webhooks/ses.go +++ b/internal/bounce/webhooks/ses.go @@ -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"` @@ -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") }