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 route.ts

Kiran K0e6dedbd3639
diff --git a/apps/web/app/api/utm/[id]/route.ts b/apps/web/app/api/utm/[id]/route.ts
index 44d764f0f4..78d46e2787 100644
--- a/apps/web/app/api/utm/[id]/route.ts
+++ b/apps/web/app/api/utm/[id]/route.ts
@@ -1,7 +1,10 @@
import { DubApiError } from "@/lib/api/errors";
import { withWorkspace } from "@/lib/auth";
+import { qstash } from "@/lib/cron";
import { updateUTMTemplateBodySchema } from "@/lib/zod/schemas/utm";
import { prisma } from "@dub/prisma";
+import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
+import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
// PATCH /api/utm/[id] – update a UTM template
@@ -15,6 +18,9 @@ export const PATCH = withWorkspace(
id,
projectId: workspace.id,
},
+ include: {
+ partnerGroup: true,
+ },
});
if (!template) {
@@ -35,6 +41,18 @@ export const PATCH = withWorkspace(
},
});
+ if (template.partnerGroup) {
+ waitUntil(
+ qstash.publishJSON({
+ url: `${APP_DOMAIN_WITH_NGROK}/api/cron/groups/sync-utm`,
+ body: {
+ groupId: template.partnerGroup.id,
+ utmTemplateId: template.id,
+ },
+ }),
+ );
+ }
+
return NextResponse.json(response);
} catch (error) {
if (error.code === "P2002") {