Skip to content

Commit 612c4d9

Browse files
committed
use resend.batch.send for sendDomainClaimedEmails
1 parent 3d435f3 commit 612c4d9

2 files changed

Lines changed: 22 additions & 16 deletions

File tree

apps/web/lib/api/domains/claim-dot-link-domain.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { DubApiError } from "@/lib/api/errors";
22
import { createLink } from "@/lib/api/links";
33
import { registerDomain } from "@/lib/dynadot/register-domain";
44
import { WorkspaceWithUsers } from "@/lib/types";
5-
import { sendEmail } from "@dub/email";
5+
import { resend } from "@dub/email/resend";
6+
import { VARIANT_TO_FROM_MAP } from "@dub/email/resend/constants";
67
import DomainClaimed from "@dub/email/templates/domain-claimed";
78
import { prisma } from "@dub/prisma";
89
import { DEFAULT_LINK_PROPS } from "@dub/utils";
@@ -151,7 +152,7 @@ export async function claimDotLinkDomain({
151152
return response;
152153
}
153154

154-
const sendDomainClaimedEmails = async ({
155+
export const sendDomainClaimedEmails = async ({
155156
workspace,
156157
domain,
157158
}: {
@@ -174,17 +175,22 @@ const sendDomainClaimedEmails = async ({
174175
},
175176
});
176177

177-
workspaceWithOwner.users.map(({ user }) => {
178-
if (user.email) {
179-
sendEmail({
180-
email: user.email,
181-
subject: "Successfully claimed your .link domain!",
182-
react: DomainClaimed({
183-
email: user.email,
184-
domain,
185-
workspaceSlug: workspace.slug,
186-
}),
187-
});
188-
}
189-
});
178+
const emails = workspaceWithOwner.users
179+
.filter(({ user }) => user.email)
180+
.map(({ user }) => ({
181+
from: VARIANT_TO_FROM_MAP.notifications,
182+
to: user.email!,
183+
subject: "Successfully claimed your .link domain!",
184+
react: DomainClaimed({
185+
email: user.email!,
186+
domain,
187+
workspaceSlug: workspace.slug,
188+
}),
189+
}));
190+
191+
if (emails.length > 0) {
192+
return await resend?.batch.send(emails);
193+
}
194+
195+
return null;
190196
};

packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dub/ui",
33
"description": "UI components for Dub",
4-
"version": "0.2.52",
4+
"version": "0.2.53",
55
"sideEffects": false,
66
"main": "./dist/index.js",
77
"module": "./dist/index.mjs",

0 commit comments

Comments
 (0)