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.

Merge branch 'main' into kiran/eng-281-restricted-api-keys

Kiran K392fa4da57a4
diff --cc apps/web/app/api/stripe/webhook/customer-subscription-deleted.ts
index 2e5b03ba83,b51a33990d..aec7354e76
--- a/apps/web/app/api/stripe/webhook/customer-subscription-deleted.ts
+++ b/apps/web/app/api/stripe/webhook/customer-subscription-deleted.ts
@@@ -1,5 -1,5 +1,6 @@@
+import { getAPIRateLimitForPlan } from "@/lib/api/tokens/ratelimit";
import { prisma } from "@/lib/prisma";
+ import { recordLink } from "@/lib/tinybird";
import { redis } from "@/lib/upstash";
import { FREE_PLAN, log } from "@dub/utils";
import { sendEmail } from "emails";
@@@ -74,17 -84,30 +85,43 @@@ export async function customerSubscript
usersLimit: FREE_PLAN.limits.users!,
},
}),
+
++ // update rate limit for all restricted tokens for the workspace
+ prisma.restrictedToken.updateMany({
+ where: {
+ projectId: workspace.id,
+ },
+ data: {
+ rateLimit: getAPIRateLimitForPlan("free"),
+ },
+ }),
+
+ // remove root domain link for all domains from MySQL
+ prisma.link.updateMany({
+ where: {
+ id: {
+ in: workspaceLinks.map(({ id }) => id),
+ },
+ },
+ data: {
+ url: "",
+ },
+ }),
++
pipeline.exec(),
++
+ // record root domain link for all domains from Tinybird
+ recordLink(
+ workspaceLinks.map((link) => ({
+ link_id: link.id,
+ domain: link.domain,
+ key: link.key,
+ url: link.url,
+ tag_ids: link.tags.map((tag) => tag.tagId),
+ workspace_id: link.projectId,
+ created_at: link.createdAt,
+ })),
+ ),
log({
message:
":cry: Workspace *`" + workspace.slug + "`* deleted their subscription",