The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update
Kiran K0913c70ad2c8
diff --git a/apps/web/app/api/links/bulk/route.ts b/apps/web/app/api/links/bulk/route.tsindex fe5fe0f12f..14a60f4b79 100644--- a/apps/web/app/api/links/bulk/route.ts+++ b/apps/web/app/api/links/bulk/route.ts@@ -29,9 +29,6 @@ export const POST = withWorkspace(throwIfLinksUsageExceeded(workspace);- // TODO:- // Check folder permissions-const links = bulkCreateLinksBodySchema.parse(await parseRequestBody(req));if (workspace.linksUsage + links.length > workspace.linksLimit &&diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.tsindex 4b1c082458..356d20a0ee 100644--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@ -103,16 +103,6 @@ export const POST = withWorkspace(}}- // Check if the user has edit access to the folder- if (body.folderId) {- await throwIfFolderActionDenied({- folderId: body.folderId,- workspaceId: workspace.id,- userId: session.user.id,- requiredPermission: "folders.links.write",- });- }-const { link, error, code } = await processLink({payload: body,workspace,diff --git a/apps/web/app/api/links/upsert/route.ts b/apps/web/app/api/links/upsert/route.tsindex 261f71c1fc..452b914531 100644--- a/apps/web/app/api/links/upsert/route.ts+++ b/apps/web/app/api/links/upsert/route.ts@@ -20,15 +20,6 @@ export const PUT = withWorkspace(const bodyRaw = await parseRequestBody(req);const body = createLinkBodySchema.parse(bodyRaw);- if (body.folderId) {- await throwIfFolderActionDenied({- folderId: body.folderId,- workspaceId: workspace.id,- userId: session.user.id,- requiredPermission: "folders.links.write",- });- }-const link = await prisma.link.findFirst({where: {projectId: workspace.id,diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.tsindex fbca7e366e..1713d779cb 100644--- a/apps/web/lib/api/links/process-link.ts+++ b/apps/web/lib/api/links/process-link.ts@@ -1,4 +1,6 @@import { isBlacklistedDomain, updateConfig } from "@/lib/edge-config";+import { getFolderWithUser } from "@/lib/link-folder/get-folder";+import { canPerformActionOnFolder } from "@/lib/link-folder/permissions";import { getPangeaDomainIntel } from "@/lib/pangea";import { checkIfUserExists, getRandomKey } from "@/lib/planetscale";import { prisma } from "@/lib/prisma";@@ -326,18 +328,23 @@ export async function processLink<T extends Record<string, any>>({}// Folder checks- if (folderId && workspace) {- const folder = await prisma.folder.findUnique({- where: {- id: folderId,- projectId: workspace.id,- },+ if (folderId && workspace && userId) {+ const { folder, folderUser } = await getFolderWithUser({+ workspaceId: workspace.id,+ folderId,+ userId,});- if (!folder) {+ if (+ !canPerformActionOnFolder({+ folder,+ folderUser,+ requiredPermission: "folders.links.write",+ })+ ) {return {link: payload,- error: "Folder does not exist.",+ error: "You are not allowed to perform this action on this folder.",code: "unprocessable_entity",};}