Skip to content

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

fix: add to allow list (#2171)

Marc Seitz9926a91954d9
diff --git a/ee/features/dataroom-invitations/api/link-invite.ts b/ee/features/dataroom-invitations/api/link-invite.ts
index 46639021..742e1b96 100644
--- a/ee/features/dataroom-invitations/api/link-invite.ts
+++ b/ee/features/dataroom-invitations/api/link-invite.ts
@@ -224,6 +224,35 @@ export default async function handle(
throw error;
}
+ // If the link already enforces an allow list, merge the new invitee emails
+ // into it so recipients retain access. We never wipe pre-existing entries
+ // even if the user cleared them from the modal textarea. Re-read inside a
+ // transaction so concurrent updates to allowList are not clobbered.
+ if ((link.allowList ?? []).length > 0) {
+ await prisma.$transaction(async (tx) => {
+ const current = await tx.link.findUnique({
+ where: { id: link.id },
+ select: { allowList: true },
+ });
+
+ const currentAllowList = current?.allowList ?? [];
+ if (currentAllowList.length === 0) {
+ return;
+ }
+
+ const mergedAllowList = Array.from(
+ new Set([...currentAllowList, ...validEmails]),
+ );
+
+ if (mergedAllowList.length !== currentAllowList.length) {
+ await tx.link.update({
+ where: { id: link.id },
+ data: { allowList: mergedAllowList },
+ });
+ }
+ });
+ }
+
const linkUrl = constructLinkUrl(link);
const successes: string[] = [];