Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update email-opened.ts

Steven Teyee129d876b7f
diff --git a/apps/web/app/api/resend/webhook/email-opened.ts b/apps/web/app/api/resend/webhook/email-opened.ts
index c449ae8f5d..9df9282a5d 100644
--- a/apps/web/app/api/resend/webhook/email-opened.ts
+++ b/apps/web/app/api/resend/webhook/email-opened.ts
@@ -1,14 +1,17 @@
import { prisma } from "@dub/prisma";
export async function emailOpened({
- tags,
email_id: emailId,
+ tags,
}: {
- tags?: Record<string, string>;
email_id: string;
+ tags?: Record<string, string>;
}) {
// Ignore if not a message notification
if (!tags || tags.type !== "message-notification") {
+ console.log(
+ `Ignoring email.opened webhook for email ${emailId} because it's not a message-notification...`,
+ );
return;
}
@@ -17,7 +20,6 @@ export async function emailOpened({
);
const res = await prisma.$transaction(async (tx) => {
- // TODO: refactor this to use findUnique once we add `emailId` as a unique index
const notificationEmail = await tx.notificationEmail.update({
where: {
emailId,
@@ -32,6 +34,7 @@ export async function emailOpened({
`Updated notification email ${notificationEmail.id} with Resend email id ${emailId} to opened at ${new Date()}`,
);
+ // TODO: remove this once we make programId and partnerId required
if (!notificationEmail.programId || !notificationEmail.partnerId) {
return notificationEmail;
}