Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions apps/web/src/server/service/ses-hook-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export async function parseSesHook(data: SesEvent) {
return false;
}

const existingEvent = await db.emailEvent.findFirst({
where: {
emailId: email.id,
status: mailStatus,
},
});

if (
email.latestStatus === mailStatus &&
mailStatus === EmailStatus.DELIVERY_DELAYED
Expand All @@ -67,6 +74,7 @@ export async function parseSesHook(data: SesEvent) {
(mailData as SesBounce).bounceType === "Permanent";

if (
!existingEvent &&
[
"DELIVERED",
"OPENED",
Expand Down Expand Up @@ -147,14 +155,7 @@ export async function parseSesHook(data: SesEvent) {
mailData: data,
});

const mailEvent = await db.emailEvent.findFirst({
where: {
emailId: email.id,
status: mailStatus,
},
});

if (!mailEvent) {
if (!existingEvent) {
await updateCampaignAnalytics(
email.campaignId,
mailStatus,
Expand Down