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[]
|
dailyEmailUsages DailyEmailUsage[]
|
||||||
subscription Subscription[]
|
subscription Subscription[]
|
||||||
invites TeamInvite[]
|
invites TeamInvite[]
|
||||||
SuppressionList SuppressionList[]
|
suppressionList SuppressionList[]
|
||||||
|
emailEvents EmailEvent[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model TeamInvite {
|
model TeamInvite {
|
||||||
@@ -261,10 +262,13 @@ model EmailEvent {
|
|||||||
emailId String
|
emailId String
|
||||||
status EmailStatus
|
status EmailStatus
|
||||||
data Json?
|
data Json?
|
||||||
|
teamId Int
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
email Email @relation(fields: [emailId], references: [id], onDelete: Cascade)
|
email Email @relation(fields: [emailId], references: [id], onDelete: Cascade)
|
||||||
|
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
@@index([emailId])
|
@@index([emailId])
|
||||||
|
@@index([teamId])
|
||||||
}
|
}
|
||||||
|
|
||||||
model ContactBook {
|
model ContactBook {
|
||||||
|
@@ -331,6 +331,7 @@ async function processContactEmail(jobData: CampaignEmailJob) {
|
|||||||
data: {
|
data: {
|
||||||
error: "Contact email is suppressed. No email sent.",
|
error: "Contact email is suppressed. No email sent.",
|
||||||
},
|
},
|
||||||
|
teamId: emailConfig.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -403,6 +403,7 @@ async function executeEmail(job: QueueEmailJob) {
|
|||||||
data: {
|
data: {
|
||||||
error: error.toString(),
|
error: error.toString(),
|
||||||
},
|
},
|
||||||
|
teamId: email.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await db.email.update({
|
await db.email.update({
|
||||||
|
@@ -132,6 +132,7 @@ export async function sendEmail(
|
|||||||
data: {
|
data: {
|
||||||
error: "All TO recipients are suppressed. No emails to send.",
|
error: "All TO recipients are suppressed. No emails to send.",
|
||||||
},
|
},
|
||||||
|
teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -260,6 +261,7 @@ export async function sendEmail(
|
|||||||
data: {
|
data: {
|
||||||
error: error.toString(),
|
error: error.toString(),
|
||||||
},
|
},
|
||||||
|
teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await db.email.update({
|
await db.email.update({
|
||||||
@@ -327,6 +329,7 @@ export async function cancelEmail(emailId: string) {
|
|||||||
data: {
|
data: {
|
||||||
emailId,
|
emailId,
|
||||||
status: "CANCELLED",
|
status: "CANCELLED",
|
||||||
|
teamId: email.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -543,6 +546,7 @@ export async function sendBulkEmails(
|
|||||||
data: {
|
data: {
|
||||||
error: "All TO recipients are suppressed. No emails to send.",
|
error: "All TO recipients are suppressed. No emails to send.",
|
||||||
},
|
},
|
||||||
|
teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -733,6 +737,7 @@ export async function sendBulkEmails(
|
|||||||
data: {
|
data: {
|
||||||
error: error.toString(),
|
error: error.toString(),
|
||||||
},
|
},
|
||||||
|
teamId: email.email.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await db.email.update({
|
await db.email.update({
|
||||||
|
@@ -249,6 +249,7 @@ export async function parseSesHook(data: SesEvent) {
|
|||||||
emailId: email.id,
|
emailId: email.id,
|
||||||
status: mailStatus,
|
status: mailStatus,
|
||||||
data: mailData as any,
|
data: mailData as any,
|
||||||
|
teamId: email.teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user