Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: watermark on partial folder downloads
Marc Seitz228364781e1b
diff --git a/pages/api/links/download/dataroom-folder.ts b/pages/api/links/download/dataroom-folder.tsindex c38eaaf5..c4376103 100644--- a/pages/api/links/download/dataroom-folder.ts+++ b/pages/api/links/download/dataroom-folder.ts@@ -7,6 +7,7 @@ import slugify from "@sindresorhus/slugify";import { getLambdaClientForTeam } from "@/lib/files/aws-client";import prisma from "@/lib/prisma";+import { getIpAddress } from "@/lib/utils/ip";export const config = {maxDuration: 180,@@ -43,12 +44,16 @@ export default async function handler(select: {id: true,viewedAt: true,+ viewerEmail: true,link: {select: {teamId: true,allowDownload: true,expiresAt: true,isArchived: true,+ enableWatermark: true,+ watermarkConfig: true,+ name: true,permissionGroupId: true,},},@@ -125,6 +130,8 @@ export default async function handler(file: true,storageType: true,originalFile: true,+ numPages: true,+ contentType: true,},take: 1,},@@ -241,7 +248,11 @@ export default async function handler()continue;- const fileKey = version.originalFile ?? version.file;+ // Use .file if watermark is enabled and document is PDF, otherwise use .originalFile+ const fileKey =+ view.link.enableWatermark && version.type === "pdf"+ ? version.file+ : (version.originalFile ?? version.file);addFileToStructure(folder.path, rootFolder, doc.document.name, fileKey);}}@@ -268,6 +279,19 @@ export default async function handler(sourceBucket: storageConfig.bucket,fileKeys,folderStructure,+ watermarkConfig: view.link.enableWatermark+ ? {+ enabled: true,+ config: view.link.watermarkConfig,+ viewerData: {+ email: view.viewerEmail,+ date: new Date(view.viewedAt).toLocaleDateString(),+ time: new Date(view.viewedAt).toLocaleTimeString(),+ link: view.link.name,+ ipAddress: getIpAddress(req.headers),+ },+ }+ : { enabled: false },}),};