Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: add dataroomId to add new document to dataroom automatically
Marc Seitz073e39aae657
diff --git a/pages/api/webhooks/services/[...path]/index.ts b/pages/api/webhooks/services/[...path]/index.tsindex 7242bb1a..f7369755 100644--- a/pages/api/webhooks/services/[...path]/index.ts+++ b/pages/api/webhooks/services/[...path]/index.ts@@ -107,12 +107,26 @@ export default async function incomingWebhookHandler(}// 3. Validate request body- const { fileUrl, name, contentType } = req.body;+ const { fileUrl, name, contentType, dataroomId } = req.body;if (!fileUrl) {return res.status(400).json({ error: "File URL is required" });}+ if (dataroomId) {+ // Verify dataroom exists and belongs to team+ const dataroom = await prisma.dataroom.findUnique({+ where: {+ id: dataroomId,+ teamId: incomingWebhook.teamId,+ },+ });++ if (!dataroom) {+ return res.status(400).json({ error: "Invalid dataroom ID" });+ }+ }+// Check if the content type is supportedconst supportedContentType = getSupportedContentType(contentType);if (!supportedContentType) {@@ -171,9 +185,22 @@ export default async function incomingWebhookHandler(const document = await documentCreationResponse.json();+ // If dataroomId was provided, create the relationship+ if (dataroomId) {+ await prisma.dataroomDocument.create({+ data: {+ dataroomId,+ documentId: document.id,+ },+ });+ }+return res.status(200).json({- message: "Document created successfully",+ message: `Document created successfully${+ dataroomId ? ` and added to dataroom` : ""+ }`,documentId: document.id,+ dataroomId: dataroomId ?? undefined,});} catch (error) {console.error("Webhook error:", error);