The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update route.ts
Kiran K3bea412dae4f
diff --git a/apps/web/app/(ee)/api/campaigns/[campaignId]/route.ts b/apps/web/app/(ee)/api/campaigns/[campaignId]/route.tsindex 4b6402607f..3b7623e51f 100644--- a/apps/web/app/(ee)/api/campaigns/[campaignId]/route.ts+++ b/apps/web/app/(ee)/api/campaigns/[campaignId]/route.ts@@ -143,13 +143,21 @@ export const PATCH = withWorkspace(return;}- if (updatedCampaign.status === "active") {+ // Decide whether to schedule the workflow or delete the schedule+ const shouldSchedule =+ (campaign.status === "draft" || campaign.status === "paused") &&+ updatedCampaign.status === "active";++ const shouldDeleteSchedule =+ campaign.status === "active" && updatedCampaign.status === "paused";++ if (shouldSchedule) {await qstash.schedules.create({destination: `${APP_DOMAIN_WITH_NGROK}/api/cron/workflows/${updatedCampaign.workflow.id}`,cron: "0 */12 * * *", // Every 12 hoursscheduleId: updatedCampaign.workflow.id,});- } else {+ } else if (shouldDeleteSchedule) {await qstash.schedules.delete(updatedCampaign.workflow.id);}})(),