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.

getFolderIdsToFilter when `tenantId` is passed

Steven Tey5ed73c538af4
diff --git a/apps/web/app/api/links/count/route.ts b/apps/web/app/api/links/count/route.ts
index da23af1a7e..68b16be4ff 100644
--- a/apps/web/app/api/links/count/route.ts
+++ b/apps/web/app/api/links/count/route.ts
@@ -11,8 +11,16 @@ import { NextResponse } from "next/server";
export const GET = withWorkspace(
async ({ headers, searchParams, workspace, session }) => {
const params = getLinksCountQuerySchema.parse(searchParams);
- const { groupBy, domain, folderId, search, tagId, tagIds, tagNames } =
- params;
+ const {
+ groupBy,
+ domain,
+ folderId,
+ search,
+ tagId,
+ tagIds,
+ tagNames,
+ tenantId,
+ } = params;
if (domain) {
await getDomainOrThrow({ domain, workspace: workspace });
@@ -36,10 +44,11 @@ export const GET = withWorkspace(
/* we only need to get the folder ids if we are:
- not filtering by folder
- there's a groupBy
- - filtering by search, domain, or tags
+ - filtering by search, domain, tags, or tenantId
*/
let folderIds =
- !folderId && (groupBy || search || domain || tagId || tagIds || tagNames)
+ !folderId &&
+ (groupBy || search || domain || tagId || tagIds || tagNames || tenantId)
? await getFolderIdsToFilter({
workspace,
userId: session.user.id,
diff --git a/apps/web/app/api/links/route.ts b/apps/web/app/api/links/route.ts
index d3aa3e4562..e8cd28748b 100644
--- a/apps/web/app/api/links/route.ts
+++ b/apps/web/app/api/links/route.ts
@@ -22,7 +22,8 @@ import { NextResponse } from "next/server";
export const GET = withWorkspace(
async ({ headers, searchParams, workspace, session }) => {
const params = getLinksQuerySchemaExtended.parse(searchParams);
- const { domain, folderId, search, tagId, tagIds, tagNames } = params;
+ const { domain, folderId, search, tagId, tagIds, tagNames, tenantId } =
+ params;
if (domain) {
await getDomainOrThrow({ workspace, domain });
@@ -40,10 +41,10 @@ export const GET = withWorkspace(
/* we only need to get the folder ids if we are:
- not filtering by folder
- - filtering by search, domain, or tags
+ - filtering by search, domain, tags, or tenantId
*/
let folderIds =
- !folderId && (search || domain || tagId || tagIds || tagNames)
+ !folderId && (search || domain || tagId || tagIds || tagNames || tenantId)
? await getFolderIdsToFilter({
workspace,
userId: session.user.id,