The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
optimize premium lapsed domain checks
Steven Tey61e091268d2d
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex faf38653a7..6bdda1e1dc 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -142,9 +142,6 @@ export async function processLink<T extends Record<string, any>>({const domains = workspace? await prisma.domain.findMany({where: { projectId: workspace.id },- include: {- registeredDomain: true,- },}): [];@@ -220,17 +217,22 @@ export async function processLink<T extends Record<string, any>>({};// else, check if the domain is a free .link and whether the workspace is pro+- } else if (- domain.endsWith(".link") &&- workspace?.plan === "free" &&- domains?.find((d) => d.slug === domain)?.registeredDomain- ) {- return {- link: payload,- error:- "You can only use your free .link domain on a Pro plan and above. Upgrade to Pro to use this domain.",- code: "forbidden",- };+ } else if (domain.endsWith(".link") && workspace?.plan === "free") {+ // Dub provisioned .link domains can only be used on a Pro plan and above+ const domainId = domains?.find((d) => d.slug === domain)?.id;+ const registeredDomain = await prisma.registeredDomain.findUnique({+ where: {+ domainId,+ },+ });+ if (registeredDomain) {+ return {+ link: payload,+ error:+ "You can only use your free .link domain on a Pro plan and above. Upgrade to Pro to use this domain.",+ code: "forbidden",+ };+ }}if (!key) {diff --git a/apps/web/prisma/schema/domain.prisma b/apps/web/prisma/schema/domain.prismaindex e9e0eb1b25..10291881ef 100644--- a/apps/web/prisma/schema/domain.prisma+++ b/apps/web/prisma/schema/domain.prisma@@ -27,7 +27,7 @@ model RegisteredDomain {updatedAt DateTime @updatedAtexpiresAt DateTime- project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)+ project Project @relation(fields: [projectId], references: [id])projectId Stringdomain Domain @relation(fields: [domainId], references: [id])domainId String @unique