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.

Update coupon-deleted.ts

Kiran K893a752d4d5c
diff --git a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts
index d4eb6e765c..edbd52c58f 100644
--- a/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts
+++ b/apps/web/app/(ee)/api/stripe/integration/webhook/coupon-deleted.ts
@@ -6,6 +6,7 @@ import { VARIANT_TO_FROM_MAP } from "@dub/email/resend/constants";
import DiscountDeleted from "@dub/email/templates/discount-deleted";
import { pluck } from "@dub/utils";
import { DiscountProvider } from "@prisma/client";
+import { waitUntil } from "@vercel/functions";
import type Stripe from "stripe";
import { WebhookHandlerInput, WebhookHandlerResponse } from "./types";
@@ -82,23 +83,27 @@ export async function couponDeleted({
})),
);
- const { users } = await getWorkspaceUsers({
- workspaceId: workspace.id,
- role: "owner",
- });
+ waitUntil(
+ (async () => {
+ const { users } = await getWorkspaceUsers({
+ workspaceId: workspace.id,
+ role: "owner",
+ });
- await sendBatchEmail(
- users.map((user) => ({
- from: VARIANT_TO_FROM_MAP.notifications,
- to: user.email,
- subject: "Your discount has been deleted",
- react: DiscountDeleted({
- email: user.email,
- coupon: {
- id: coupon.id,
- },
- }),
- })),
+ await sendBatchEmail(
+ users.map((user) => ({
+ from: VARIANT_TO_FROM_MAP.notifications,
+ to: user.email,
+ subject: "Your discount has been deleted",
+ react: DiscountDeleted({
+ email: user.email,
+ coupon: {
+ id: coupon.id,
+ },
+ }),
+ })),
+ );
+ })(),
);
return {