This commit is contained in:
KM Koushik
2025-09-10 22:36:39 +10:00
parent 0817b0c7a5
commit 1ae6257c11
4 changed files with 30 additions and 23 deletions
@@ -60,17 +60,12 @@ function send(app: PublicAPIApp) {
const team = c.var.team;
const emailId = c.req.param("emailId");
const whereClause: { id: string; teamId: number; domainId?: number } = {
id: emailId,
teamId: team.id,
};
if (team.apiKey.domainId !== null) {
whereClause.domainId = team.apiKey.domainId;
}
const email = await db.email.findUnique({
where: whereClause,
where: {
id: emailId,
teamId: team.id,
domainId: team.apiKey.domainId ?? undefined,
},
select: {
id: true,
teamId: true,
@@ -48,7 +48,11 @@ function updateEmailScheduledAt(app: PublicAPIApp) {
const team = c.var.team;
const emailId = c.req.param("emailId");
await checkIsValidEmailIdWithDomainRestriction(emailId, team.id, team.apiKey.domainId);
await checkIsValidEmailIdWithDomainRestriction(
emailId,
team.id,
team.apiKey.domainId ?? undefined
);
await updateEmail(emailId, {
scheduledAt: c.req.valid("json").scheduledAt,