Skip to content

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

feat: add createLink to incoming webhook

Marc Seitz96e7ae43c27c
diff --git a/pages/api/teams/[teamId]/documents/index.ts b/pages/api/teams/[teamId]/documents/index.ts
index 343753fa..8820e380 100644
--- a/pages/api/teams/[teamId]/documents/index.ts
+++ b/pages/api/teams/[teamId]/documents/index.ts
@@ -21,6 +21,7 @@ import { CustomUser } from "@/lib/types";
import { getExtension, log } from "@/lib/utils";
import { conversionQueue } from "@/lib/utils/trigger-utils";
import { sendDocumentCreatedWebhook } from "@/lib/webhook/triggers/document-created";
+import { sendLinkCreatedWebhook } from "@/lib/webhook/triggers/link-created";
export const config = {
// in order to enable `waitUntil` function
@@ -433,12 +434,22 @@ export default async function handle(
}
waitUntil(
- sendDocumentCreatedWebhook({
- teamId,
- data: {
- document_id: document.id,
- },
- }),
+ Promise.all([
+ sendDocumentCreatedWebhook({
+ teamId,
+ data: {
+ document_id: document.id,
+ },
+ }),
+ createLink &&
+ sendLinkCreatedWebhook({
+ teamId,
+ data: {
+ document_id: document.id,
+ link_id: document.links[0].id,
+ },
+ }),
+ ]),
);
return res.status(201).json(document);
diff --git a/pages/api/webhooks/services/[...path]/index.ts b/pages/api/webhooks/services/[...path]/index.ts
index d37ff412..2dea78cf 100644
--- a/pages/api/webhooks/services/[...path]/index.ts
+++ b/pages/api/webhooks/services/[...path]/index.ts
@@ -107,7 +107,7 @@ export default async function incomingWebhookHandler(
}
// 3. Validate request body
- const { fileUrl, name, contentType, dataroomId } = req.body;
+ const { fileUrl, name, contentType, dataroomId, createLink } = req.body;
if (!fileUrl) {
return res.status(400).json({ error: "File URL is required" });
@@ -177,6 +177,7 @@ export default async function incomingWebhookHandler(
teamId: incomingWebhook.teamId,
numPages: 1,
token: token,
+ createLink: createLink,
});
if (!documentCreationResponse.ok) {