add teamId to email events (#194)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `teamId` to the `EmailEvent` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "EmailEvent" ADD COLUMN "teamId" INTEGER NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "EmailEvent_teamId_idx" ON "EmailEvent"("teamId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "EmailEvent" ADD CONSTRAINT "EmailEvent_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
@@ -117,7 +117,8 @@ model Team {
|
||||
dailyEmailUsages DailyEmailUsage[]
|
||||
subscription Subscription[]
|
||||
invites TeamInvite[]
|
||||
SuppressionList SuppressionList[]
|
||||
suppressionList SuppressionList[]
|
||||
emailEvents EmailEvent[]
|
||||
}
|
||||
|
||||
model TeamInvite {
|
||||
@@ -261,10 +262,13 @@ model EmailEvent {
|
||||
emailId String
|
||||
status EmailStatus
|
||||
data Json?
|
||||
teamId Int
|
||||
createdAt DateTime @default(now())
|
||||
email Email @relation(fields: [emailId], references: [id], onDelete: Cascade)
|
||||
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([emailId])
|
||||
@@index([teamId])
|
||||
}
|
||||
|
||||
model ContactBook {
|
||||
|
@@ -331,6 +331,7 @@ async function processContactEmail(jobData: CampaignEmailJob) {
|
||||
data: {
|
||||
error: "Contact email is suppressed. No email sent.",
|
||||
},
|
||||
teamId: emailConfig.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
|
@@ -403,6 +403,7 @@ async function executeEmail(job: QueueEmailJob) {
|
||||
data: {
|
||||
error: error.toString(),
|
||||
},
|
||||
teamId: email.teamId,
|
||||
},
|
||||
});
|
||||
await db.email.update({
|
||||
|
@@ -132,6 +132,7 @@ export async function sendEmail(
|
||||
data: {
|
||||
error: "All TO recipients are suppressed. No emails to send.",
|
||||
},
|
||||
teamId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -260,6 +261,7 @@ export async function sendEmail(
|
||||
data: {
|
||||
error: error.toString(),
|
||||
},
|
||||
teamId,
|
||||
},
|
||||
});
|
||||
await db.email.update({
|
||||
@@ -327,6 +329,7 @@ export async function cancelEmail(emailId: string) {
|
||||
data: {
|
||||
emailId,
|
||||
status: "CANCELLED",
|
||||
teamId: email.teamId,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -543,6 +546,7 @@ export async function sendBulkEmails(
|
||||
data: {
|
||||
error: "All TO recipients are suppressed. No emails to send.",
|
||||
},
|
||||
teamId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -733,6 +737,7 @@ export async function sendBulkEmails(
|
||||
data: {
|
||||
error: error.toString(),
|
||||
},
|
||||
teamId: email.email.teamId,
|
||||
},
|
||||
});
|
||||
await db.email.update({
|
||||
|
@@ -249,6 +249,7 @@ export async function parseSesHook(data: SesEvent) {
|
||||
emailId: email.id,
|
||||
status: mailStatus,
|
||||
data: mailData as any,
|
||||
teamId: email.teamId,
|
||||
},
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user