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.

Follow up PR for `shortLink`

Steven Tey54ad9b609e66
diff --git a/apps/web/lib/api/links/get-links-for-workspace.ts b/apps/web/lib/api/links/get-links-for-workspace.ts
index 4ccff8eba3..726ea42561 100644
--- a/apps/web/lib/api/links/get-links-for-workspace.ts
+++ b/apps/web/lib/api/links/get-links-for-workspace.ts
@@ -31,7 +31,7 @@ export async function getLinksForWorkspace({
...(search && {
OR: [
{
- key: { contains: search },
+ shortLink: { contains: search },
},
{
url: { contains: search },
diff --git a/apps/web/lib/api/links/utils/transform-link.ts b/apps/web/lib/api/links/utils/transform-link.ts
index d555e29a8c..950d5819d6 100644
--- a/apps/web/lib/api/links/utils/transform-link.ts
+++ b/apps/web/lib/api/links/utils/transform-link.ts
@@ -1,4 +1,3 @@
-import { linkConstructor } from "@dub/utils";
import { Link, Tag } from "@prisma/client";
export type LinkWithTags = Link & {
@@ -11,8 +10,6 @@ export const transformLink = (link: LinkWithTags) => {
return {
...link,
- shortLink:
- link.shortLink ?? linkConstructor({ domain: link.domain, key: link.key }),
tagId: tags?.[0]?.id ?? null, // backwards compatibility
tags,
qrCode: `https://api.dub.co/qr?url=${link.shortLink}?qr=1`,
diff --git a/apps/web/lib/integrations/slack/slash-commands.ts b/apps/web/lib/integrations/slack/slash-commands.ts
index fd97a60b53..823aa0b585 100644
--- a/apps/web/lib/integrations/slack/slash-commands.ts
+++ b/apps/web/lib/integrations/slack/slash-commands.ts
@@ -163,6 +163,6 @@ const createShortLink = async ({
const { shortLink } = await createLink(link);
return {
- text: shortLink as string, // TODO: Once shortLink is not nullable, we can remove the type assertion
+ text: shortLink,
};
};
diff --git a/apps/web/prisma/schema/link.prisma b/apps/web/prisma/schema/link.prisma
index 85fbe716de..e69056aeff 100644
--- a/apps/web/prisma/schema/link.prisma
+++ b/apps/web/prisma/schema/link.prisma
@@ -3,7 +3,7 @@ model Link {
domain String // domain of the link (e.g. dub.sh) – also stored on Redis
key String // key of the link (e.g. /github) – also stored on Redis
url String @db.LongText // target url (e.g. https://github.com/dubinc/dub) – also stored on Redis
- shortLink String? @unique @db.VarChar(400) // new column for the full short link
+ shortLink String @unique @db.VarChar(400) // new column for the full short link
archived Boolean @default(false) // whether the link is archived or not
expiresAt DateTime? // when the link expires – stored on Redis via ttl
expiredUrl String? @db.LongText // URL to redirect the user to when the link is expired