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.

only fetch verified emailDomains

Steven Tey1ca2ff719efb
diff --git a/apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts b/apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts
index d39842a1aa..94f57eb02a 100644
--- a/apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts
+++ b/apps/web/app/(ee)/api/campaigns/[campaignId]/preview/route.ts
@@ -39,7 +39,11 @@ export const POST = withWorkspace(
programId,
workspaceId: workspace.id,
include: {
- emailDomains: true,
+ emailDomains: {
+ where: {
+ status: "verified",
+ },
+ },
},
}),
diff --git a/apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts b/apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts
index fc0ba0efca..7592ae5691 100644
--- a/apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts
+++ b/apps/web/app/(ee)/api/cron/bounties/notify-partners/route.ts
@@ -52,7 +52,11 @@ export async function POST(req: Request) {
groups: true,
program: {
include: {
- emailDomains: true,
+ emailDomains: {
+ where: {
+ status: "verified",
+ },
+ },
},
},
},
@@ -132,16 +136,13 @@ export async function POST(req: Request) {
`Sending emails to ${programEnrollments.length} partners: ${programEnrollments.map(({ partner }) => partner.email).join(", ")}`,
);
- const verifiedEmailDomain = bounty.program.emailDomains.find(
- ({ status }) => status === "verified",
- )?.slug;
-
const { data } = await sendBatchEmail(
programEnrollments.map(({ partner }) => ({
variant: "notifications",
- from: verifiedEmailDomain
- ? `${bounty.program.name} <bounties@${verifiedEmailDomain}>`
- : undefined,
+ from:
+ bounty.program.emailDomains.length > 0
+ ? `${bounty.program.name} <bounties@${bounty.program.emailDomains[0].slug}>`
+ : undefined,
to: partner.email!, // coerce the type here because we've already filtered out partners with no email in the prisma query
subject: `New bounty available for ${bounty.program.name}`,
replyTo: bounty.program.supportEmail || "noreply",
diff --git a/apps/web/lib/actions/partners/invite-partner.ts b/apps/web/lib/actions/partners/invite-partner.ts
index beaa5c2c15..69bbb2b4cd 100644
--- a/apps/web/lib/actions/partners/invite-partner.ts
+++ b/apps/web/lib/actions/partners/invite-partner.ts
@@ -25,7 +25,11 @@ export const invitePartnerAction = authActionClient
workspaceId: workspace.id,
programId,
include: {
- emailDomains: true,
+ emailDomains: {
+ where: {
+ status: "verified",
+ },
+ },
},
}),
@@ -88,7 +92,7 @@ export const invitePartnerAction = authActionClient
inviteEmailData?.subject ||
`${program.name} invited you to join Dub Partners`,
variant: "notifications",
- // use the first email domain as the from email address
+ // use the first verified email domain as the from email address
from:
program.emailDomains.length > 0
? `${program.name} <partners@${program.emailDomains[0].slug}>`