Skip to content

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

feat: add additional checks

Marc Seitz819d5d0e3ce5
diff --git a/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts b/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
index ce12c6d8..28c74f25 100644
--- a/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
+++ b/pages/api/teams/[teamId]/documents/[id]/update-link-url.ts
@@ -59,7 +59,11 @@ export default async function handle(
id: true,
file: true,
type: true,
- versions: { select: { id: true, file: true, type: true } },
+ versions: {
+ select: { id: true, file: true, type: true },
+ orderBy: { createdAt: "desc" },
+ take: 1,
+ },
},
});
@@ -73,6 +77,10 @@ export default async function handle(
.json({ message: "Document is not a link document" });
}
+ if (!document.versions[0]) {
+ return res.status(400).json({ message: "Document has no versions" });
+ }
+
// Check if URL contains blocked keywords
const keywords = await get("keywords");
if (Array.isArray(keywords) && keywords.length > 0) {