Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(email): add Resend idempotency key support

Richie McIlroya4d45ed32c42
diff --git a/packages/database/emails/config.ts b/packages/database/emails/config.ts
index 20ad371ef..ac63f9681 100644
--- a/packages/database/emails/config.ts
+++ b/packages/database/emails/config.ts
@@ -15,6 +15,7 @@ export const sendEmail = async ({
cc,
replyTo,
fromOverride,
+ idempotencyKey,
}: {
email: string;
subject: string;
@@ -25,6 +26,7 @@ export const sendEmail = async ({
cc?: string | string[];
replyTo?: string;
fromOverride?: string;
+ idempotencyKey?: string;
}) => {
const r = resend();
if (!r) {
@@ -40,13 +42,16 @@ export const sendEmail = async ({
from = "Cap Auth <[email protected]>";
else from = `auth@${serverEnv().RESEND_FROM_DOMAIN}`;
- return r.emails.send({
- from,
- to: test ? "[email protected]" : email,
- subject,
- react,
- scheduledAt,
- cc: test ? undefined : cc,
- replyTo: replyTo,
- });
+ return r.emails.send(
+ {
+ from,
+ to: test ? "[email protected]" : email,
+ subject,
+ react,
+ scheduledAt,
+ cc: test ? undefined : cc,
+ replyTo: replyTo,
+ },
+ idempotencyKey ? { idempotencyKey } : undefined,
+ );
};