Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: add folder to link export

Marc Seitze4cd98b95008
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/groups/[groupId]/links.ts b/pages/api/teams/[teamId]/datarooms/[id]/groups/[groupId]/links.ts
index f18ae435..80f2cdac 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/groups/[groupId]/links.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/groups/[groupId]/links.ts
@@ -5,7 +5,7 @@ import { getServerSession } from "next-auth/next";
import { errorhandler } from "@/lib/errorHandler";
import prisma from "@/lib/prisma";
-import { CustomUser } from "@/lib/types";
+import { CustomUser, LinkWithViews } from "@/lib/types";
import { decryptEncrpytedPassword, log } from "@/lib/utils";
export default async function handle(
@@ -75,14 +75,27 @@ export default async function handle(
},
});
- // Decrypt the password for each link
- if (links && links.length > 0) {
- links = await Promise.all(
- links.map(async (link) => {
+ let extendedLinks: LinkWithViews[] = links as LinkWithViews[];
+ if (extendedLinks && extendedLinks.length > 0) {
+ extendedLinks = await Promise.all(
+ extendedLinks.map(async (link) => {
// Decrypt the password if it exists
if (link.password !== null) {
link.password = decryptEncrpytedPassword(link.password);
}
+ // Get the upload folder name if it exists
+ if (link.enableUpload && link.uploadFolderId !== null) {
+ const folder = await prisma.dataroomFolder.findUnique({
+ where: {
+ id: link.uploadFolderId,
+ },
+ select: {
+ name: true,
+ },
+ });
+ link.uploadFolderName = folder?.name;
+ }
+ // Get the tags for the link
const tags = await prisma.tag.findMany({
where: {
items: {
@@ -108,7 +121,7 @@ export default async function handle(
);
}
- return res.status(200).json(links);
+ return res.status(200).json(extendedLinks);
} catch (error) {
log({
message: `Failed to get links for dataroom: _${dataroomId}_,group: _${groupId}_. \n\n ${error} \n\n*Metadata*: \`{teamId: ${teamId}, groupId: ${groupId}, userId: ${userId}}\``,