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.

remove fetchMetatagsAndUpdateLink

Steven Tey0d13f6853f52
diff --git a/apps/web/lib/api/links/create-link.ts b/apps/web/lib/api/links/create-link.ts
index 40e2824a84..beab130461 100644
--- a/apps/web/lib/api/links/create-link.ts
+++ b/apps/web/lib/api/links/create-link.ts
@@ -7,11 +7,7 @@ import { formatRedisLink, redis } from "@/lib/upstash";
import { APP_DOMAIN_WITH_NGROK, getParamsFromURL, truncate } from "@dub/utils";
import { Prisma } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
-import {
- combineTagIds,
- fetchMetatagsAndUpdateLink,
- transformLink,
-} from "./utils";
+import { combineTagIds, transformLink } from "./utils";
export async function createLink(link: ProcessedLinkProps) {
let { key, url, expiresAt, title, description, image, proxy, geo } = link;
@@ -116,15 +112,7 @@ export async function createLink(link: ProcessedLinkProps) {
},
}),
]
- : // if there is no title or description provided, try fetching and storing it
- !proxy && !title && !description
- ? [
- fetchMetatagsAndUpdateLink({
- url,
- linkId: response.id,
- }),
- ]
- : []),
+ : []),
// delete public links after 30 mins
!response.userId &&
qstash.publishJSON({
diff --git a/apps/web/lib/api/links/update-link.ts b/apps/web/lib/api/links/update-link.ts
index 611e734979..79cf0edd18 100644
--- a/apps/web/lib/api/links/update-link.ts
+++ b/apps/web/lib/api/links/update-link.ts
@@ -6,11 +6,7 @@ import { formatRedisLink, redis } from "@/lib/upstash";
import { SHORT_DOMAIN, getParamsFromURL, truncate } from "@dub/utils";
import { Prisma } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
-import {
- combineTagIds,
- fetchMetatagsAndUpdateLink,
- transformLink,
-} from "./utils";
+import { combineTagIds, transformLink } from "./utils";
export async function updateLink({
oldDomain = SHORT_DOMAIN,
@@ -137,18 +133,13 @@ export async function updateLink({
(changedDomain || changedKey) &&
redis.hdel(oldDomain.toLowerCase(), oldKey.toLowerCase()),
// if proxy is true and image is not stored in R2, upload image to R2
- proxy && image && !isStored(image)
- ? storage.upload(`images/${id}`, image, {
- width: 1200,
- height: 630,
- })
- : // if there is no title or description provided, try fetching and storing it
- !proxy && !title && !description
- ? fetchMetatagsAndUpdateLink({
- url,
- linkId: id,
- })
- : null,
+ proxy &&
+ image &&
+ !isStored(image) &&
+ storage.upload(`images/${id}`, image, {
+ width: 1200,
+ height: 630,
+ }),
]),
);
diff --git a/apps/web/lib/api/links/utils.ts b/apps/web/lib/api/links/utils.ts
index 55c1600675..5ad69a4682 100644
--- a/apps/web/lib/api/links/utils.ts
+++ b/apps/web/lib/api/links/utils.ts
@@ -4,7 +4,6 @@ import {
isReservedUsername,
} from "@/lib/edge-config";
import { checkIfKeyExists } from "@/lib/planetscale";
-import prisma from "@/lib/prisma";
import { WorkspaceProps } from "@/lib/types";
import {
DEFAULT_REDIRECTS,
@@ -12,11 +11,9 @@ import {
isDubDomain,
linkConstructor,
punyEncode,
- truncate,
validKeyRegex,
} from "@dub/utils";
import { Link, Tag } from "@prisma/client";
-import { getMetaTags } from "app/api/metatags/utils";
export type LinkWithTags = Link & {
tags: { tag: Pick<Tag, "id" | "name" | "color"> }[];
@@ -150,23 +147,3 @@ export const transformLink = (link: LinkWithTags) => {
workspaceId: `ws_${link.projectId}`,
};
};
-
-export async function fetchMetatagsAndUpdateLink({
- url,
- linkId,
-}: {
- url: string;
- linkId: string;
-}) {
- const { title, description, image } = await getMetaTags(url);
- await prisma.link.update({
- where: {
- id: linkId,
- },
- data: {
- title: truncate(title, 120),
- description: truncate(description, 240),
- image: image || null,
- },
- });
-}