Skip to content

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

bugFix: Notion documents are not loading in data room

Ashish Viradiya0d6a342b26b9
diff --git a/app/api/views-dataroom/route.ts b/app/api/views-dataroom/route.ts
index 0e70d735..5406c40e 100644
--- a/app/api/views-dataroom/route.ts
+++ b/app/api/views-dataroom/route.ts
@@ -4,8 +4,6 @@ import { authOptions } from "@/pages/api/auth/[...nextauth]";
import { ItemType, LinkAudienceType } from "@prisma/client";
import { ipAddress, waitUntil } from "@vercel/functions";
import { getServerSession } from "next-auth";
-import { parsePageId } from "notion-utils";
-
import { hashToken } from "@/lib/api/auth/token";
import {
DataroomSession,
@@ -16,8 +14,6 @@ import { PreviewSession, verifyPreviewSession } from "@/lib/auth/preview-auth";
import { sendOtpVerificationEmail } from "@/lib/emails/send-email-otp-verification";
import { getFile } from "@/lib/files/get-file";
import { newId } from "@/lib/id-helper";
-import notion from "@/lib/notion";
-import { addSignedUrls } from "@/lib/notion/utils";
import prisma from "@/lib/prisma";
import { ratelimit } from "@/lib/redis";
import { parseSheet } from "@/lib/sheet";
@@ -749,11 +745,8 @@ export async function POST(request: NextRequest) {
}
// if document version has pages, then return pages
- // otherwise, check if notion document,
- // if notion, return recordMap and theme from document version file
// otherwise, return file from document version
let documentPages, documentVersion;
- let recordMap, theme;
let sheetData;
if (hasPages) {
@@ -812,23 +805,6 @@ export async function POST(request: NextRequest) {
type: documentVersion.storageType,
});
}
-
- if (documentVersion.type === "notion") {
- // get theme `mode` param from document version file
- const modeMatch = documentVersion.file.match(/[?&]mode=(dark|light)/);
- theme = modeMatch ? modeMatch[1] : undefined;
-
- let notionPageId = parsePageId(documentVersion.file, { uuid: false });
- if (!notionPageId) {
- notionPageId = "";
- }
-
- const pageId = notionPageId;
- recordMap = await notion.getPage(pageId, { signFileUrls: false });
- // TODO: separately sign the file urls until PR merged and published; ref: https://github.com/NotionX/react-notion-x/issues/580#issuecomment-2542823817
- await addSignedUrls({ recordMap });
- }
-
if (documentVersion.type === "sheet") {
const document = await prisma.document.findUnique({
where: { id: documentId },
@@ -924,7 +900,7 @@ export async function POST(request: NextRequest) {
? documentVersion.file
: undefined,
pages: documentPages ? documentPages : undefined,
- notionData: recordMap ? { recordMap, theme } : undefined,
+ notionData: undefined,
sheetData:
documentVersion &&
documentVersion.type === "sheet" &&
@@ -935,9 +911,7 @@ export async function POST(request: NextRequest) {
? documentVersion.type
: documentPages
? "pdf"
- : recordMap
- ? "notion"
- : undefined,
+ : undefined,
watermarkConfig: link.enableWatermark
? link.watermarkConfig
: undefined,