Add check for SES bounce notif type (#1123)

This commit is contained in:
Haseeb Ahmad 2023-01-28 03:25:48 -05:00 committed by GitHub
parent 8985e5c24a
commit 755344e74b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -46,6 +46,7 @@ type sesNotif struct {
type sesTimestamp time.Time type sesTimestamp time.Time
type sesMail struct { type sesMail struct {
EventType string `json:"eventType"`
NotifType string `json:"notificationType"` NotifType string `json:"notificationType"`
Bounce struct { Bounce struct {
BounceType string `json:"bounceType"` 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) 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 { if len(m.Mail.Destination) == 0 {
return bounce, errors.New("no destination e-mails found in SES notification") return bounce, errors.New("no destination e-mails found in SES notification")
} }