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.

add & update deeplink

Kiran K9a6d66fbbc34
diff --git a/apps/web/app/api/domains/[domain]/route.ts b/apps/web/app/api/domains/[domain]/route.ts
index e4052a60c7..57e842e08d 100644
--- a/apps/web/app/api/domains/[domain]/route.ts
+++ b/apps/web/app/api/domains/[domain]/route.ts
@@ -15,6 +15,7 @@ import {
DomainSchema,
updateDomainBodySchema,
} from "@/lib/zod/schemas/domains";
+import { Prisma } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
@@ -37,7 +38,11 @@ export const GET = withWorkspace(
// PUT /api/domains/[domain] – edit a workspace's domain
export const PATCH = withWorkspace(
async ({ req, workspace, params }) => {
- const { slug: domain, registeredDomain } = await getDomainOrThrow({
+ const {
+ slug: domain,
+ registeredDomain,
+ deepLink: existingDeepLink,
+ } = await getDomainOrThrow({
workspace,
domain: params.domain,
dubDomainChecks: true,
@@ -49,6 +54,7 @@ export const PATCH = withWorkspace(
expiredUrl,
notFoundUrl,
archived,
+ deepLink,
} = updateDomainBodySchema.parse(await parseRequestBody(req));
if (workspace.plan === "free" && expiredUrl) {
@@ -91,6 +97,12 @@ export const PATCH = withWorkspace(
expiredUrl,
notFoundUrl,
}),
+ ...(deepLink && {
+ deepLink: {
+ ...(existingDeepLink as Prisma.JsonObject),
+ ...deepLink,
+ },
+ }),
},
include: {
registeredDomain: true,
diff --git a/apps/web/app/api/domains/route.ts b/apps/web/app/api/domains/route.ts
index 7a05de04c2..f9d7a3d68e 100644
--- a/apps/web/app/api/domains/route.ts
+++ b/apps/web/app/api/domains/route.ts
@@ -77,7 +77,7 @@ export const GET = withWorkspace(
export const POST = withWorkspace(
async ({ req, workspace, session }) => {
const body = await parseRequestBody(req);
- const { slug, placeholder, expiredUrl, notFoundUrl } =
+ const { slug, placeholder, expiredUrl, notFoundUrl, deepLink } =
createDomainBodySchema.parse(body);
const totalDomains = await prisma.domain.count({
@@ -134,6 +134,7 @@ export const POST = withWorkspace(
expiredUrl,
notFoundUrl,
}),
+ ...(deepLink && { deepLink }),
},
}),
diff --git a/apps/web/lib/zod/schemas/domains.ts b/apps/web/lib/zod/schemas/domains.ts
index 7ab19ed9d0..f2618fcc78 100644
--- a/apps/web/lib/zod/schemas/domains.ts
+++ b/apps/web/lib/zod/schemas/domains.ts
@@ -85,6 +85,13 @@ export const getDefaultDomainsQuerySchema = getDomainsQuerySchema.pick({
search: true,
});
+const deepLink = z.object({
+ iosAppId: z.string().nullish().default(null),
+ iosTeamId: z.string().nullish().default(null),
+ androidPackageName: z.string().nullish().default(null),
+ androidSha256CertFingerprints: z.string().nullish().default(null),
+});
+
export const createDomainBodySchema = z.object({
slug: z
.string({ required_error: "slug is required" })
@@ -119,6 +126,7 @@ export const createDomainBodySchema = z.object({
"Provide context to your teammates in the link creation modal by showing them an example of a link to be shortened.",
)
.openapi({ example: "https://dub.co/help/article/what-is-dub" }),
+ deepLink: deepLink.nullish().describe("Deep link configuration."),
});
export const updateDomainBodySchema = createDomainBodySchema.partial();
diff --git a/apps/web/prisma/schema/domain.prisma b/apps/web/prisma/schema/domain.prisma
index 9216da579c..f624ac48be 100644
--- a/apps/web/prisma/schema/domain.prisma
+++ b/apps/web/prisma/schema/domain.prisma
@@ -1,16 +1,17 @@
model Domain {
- id String @id @default(cuid())
- slug String @unique
- verified Boolean @default(false)
- placeholder String?
- expiredUrl String? @db.LongText // URL to redirect to for expired links
- notFoundUrl String? @db.LongText // URL to redirect to for links that don't exist
- primary Boolean @default(false)
- archived Boolean @default(false)
- lastChecked DateTime @default(now())
- links Link[]
- project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
- projectId String?
+ id String @id @default(cuid())
+ slug String @unique
+ verified Boolean @default(false)
+ placeholder String?
+ expiredUrl String? @db.LongText // URL to redirect to for expired links
+ notFoundUrl String? @db.LongText // URL to redirect to for links that don't exist
+ primary Boolean @default(false)
+ archived Boolean @default(false)
+ lastChecked DateTime @default(now())
+ deepLink Json?
+ links Link[]
+ project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
+ projectId String?
registeredDomain RegisteredDomain?
// these attributes will exist on both Link and Domain models
@@ -51,4 +52,4 @@ model DefaultDomains {
loooooooong Boolean @default(false)
projectId String @unique
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
-}
\ No newline at end of file
+}
diff --git a/apps/web/prisma/schema/webhook.prisma b/apps/web/prisma/schema/webhook.prisma
index 536c6e9638..0e7f264d84 100644
--- a/apps/web/prisma/schema/webhook.prisma
+++ b/apps/web/prisma/schema/webhook.prisma
@@ -2,6 +2,7 @@ enum WebhookReceiver {
user
zapier
make
+ slack
}
model Webhook {