Skip to content

Commit

Permalink
Parse campaign UUID in SendGrid webhook. Closes #1177.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Feb 26, 2023
1 parent dda7d44 commit da377d8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/bounce/webhooks/sendgrid.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type sendgridNotif struct {
Email string `json:"email"`
Timestamp int64 `json:"timestamp"`
Event string `json:"event"`

// SendGrid flattens all X-headers and adds them to the bounce
// event notification.
CampaignUUID string `json:"XListmonkCampaign"`
}

// Sendgrid handles Sendgrid/SNS webhook notifications including confirming SNS topic subscription
Expand Down Expand Up @@ -62,14 +66,15 @@ func (s *Sendgrid) ProcessBounce(sig, timestamp string, b []byte) ([]models.Boun
}

tstamp := time.Unix(n.Timestamp, 0)
b := models.Bounce{
Email: strings.ToLower(n.Email),
Type: models.BounceTypeHard,
Meta: json.RawMessage(b),
Source: "sendgrid",
CreatedAt: tstamp,
bn := models.Bounce{
CampaignUUID: n.CampaignUUID,
Email: strings.ToLower(n.Email),
Type: models.BounceTypeHard,
Meta: json.RawMessage(b),
Source: "sendgrid",
CreatedAt: tstamp,
}
out = append(out, b)
out = append(out, bn)
}

return out, nil
Expand Down

0 comments on commit da377d8

Please sign in to comment.