Skip to content

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

feat: don't generate document link by default

Marc Seitz2b58cb5a213d
diff --git a/components/documents/add-document-modal.tsx b/components/documents/add-document-modal.tsx
index 8557fbe0..79826849 100644
--- a/components/documents/add-document-modal.tsx
+++ b/components/documents/add-document-modal.tsx
@@ -140,11 +140,7 @@ export function AddDocumentModal({
}
if (!newVersion) {
- // copy the link to the clipboard
- copyToClipboard(
- `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${document.links[0].id}`,
- "Document uploaded and link copied to clipboard. Redirecting to document page...",
- );
+ toast.success("Document uploaded. Redirecting to document page...");
// track the event
plausible("documentUploaded");
@@ -156,12 +152,6 @@ export function AddDocumentModal({
type: document.type,
teamId: teamId,
});
- analytics.capture("Link Added", {
- linkId: document.links[0].id,
- documentId: document.id,
- customDomain: null,
- teamId: teamId,
- });
// redirect to the document page
router.push("/documents/" + document.id);
@@ -283,6 +273,7 @@ export function AddDocumentModal({
url: notionLink,
numPages: 1,
type: "notion",
+ createLink: false,
}),
},
);
@@ -312,10 +303,8 @@ export function AddDocumentModal({
}
if (!newVersion) {
- // copy the link to the clipboard
- copyToClipboard(
- `${process.env.NEXT_PUBLIC_MARKETING_URL}/view/${document.links[0].id}`,
- "Notion Page processed and link copied to clipboard. Redirecting to document page...",
+ toast.success(
+ "Notion Page processed. Redirecting to document page...",
);
// track the event
@@ -329,12 +318,6 @@ export function AddDocumentModal({
type: "notion",
teamId: teamId,
});
- analytics.capture("Link Added", {
- linkId: document.links[0].id,
- documentId: document.id,
- customDomain: null,
- teamId: teamId,
- });
// redirect to the document page
router.push("/documents/" + document.id);
diff --git a/components/welcome/dataroom-upload.tsx b/components/welcome/dataroom-upload.tsx
index f23d8a0e..95091b05 100644
--- a/components/welcome/dataroom-upload.tsx
+++ b/components/welcome/dataroom-upload.tsx
@@ -169,7 +169,7 @@ export default function DataroomUpload({ dataroomId }: DataroomUploadProps) {
...linkData,
metaImage: blobUrl,
targetId: dataroomId,
- linkType: "DATAROOM_LINK",
+ linkType: LinkType.DATAROOM_LINK,
}),
});
diff --git a/components/welcome/notion-form.tsx b/components/welcome/notion-form.tsx
index 76378ba3..251c9708 100644
--- a/components/welcome/notion-form.tsx
+++ b/components/welcome/notion-form.tsx
@@ -91,6 +91,7 @@ export default function NotionForm() {
url: notionLink,
numPages: 1,
type: "notion",
+ createLink: true,
}),
},
);
@@ -165,7 +166,8 @@ export default function NotionForm() {
body: JSON.stringify({
...linkData,
metaImage: blobUrl,
- documentId: currentDocId,
+ targetId: currentDocId,
+ linkType: LinkType.DOCUMENT_LINK,
}),
});
diff --git a/components/welcome/special-upload.tsx b/components/welcome/special-upload.tsx
index 302e36a5..dd3c26ac 100644
--- a/components/welcome/special-upload.tsx
+++ b/components/welcome/special-upload.tsx
@@ -108,7 +108,12 @@ export default function DeckGeneratorUpload() {
supportedFileType: supportedFileType,
};
// create a document in the database
- const response = await createDocument({ documentData, teamId, numPages });
+ const response = await createDocument({
+ documentData,
+ teamId,
+ numPages,
+ createLink: true,
+ });
if (response) {
const document = await response.json();
@@ -171,7 +176,7 @@ export default function DeckGeneratorUpload() {
...linkData,
metaImage: blobUrl,
targetId: currentDocId,
- linkType: "DOCUMENT_LINK",
+ linkType: LinkType.DOCUMENT_LINK,
}),
});
diff --git a/components/welcome/upload.tsx b/components/welcome/upload.tsx
index 963cc72b..71d84365 100644
--- a/components/welcome/upload.tsx
+++ b/components/welcome/upload.tsx
@@ -88,7 +88,12 @@ export default function Upload() {
supportedFileType: supportedFileType,
};
// create a document in the database
- const response = await createDocument({ documentData, teamId, numPages });
+ const response = await createDocument({
+ documentData,
+ teamId,
+ numPages,
+ createLink: true,
+ });
if (response) {
const document = await response.json();
@@ -152,7 +157,7 @@ export default function Upload() {
...linkData,
metaImage: blobUrl,
targetId: currentDocId,
- linkType: "DOCUMENT_LINK",
+ linkType: LinkType.DOCUMENT_LINK,
}),
});
diff --git a/lib/documents/create-document.ts b/lib/documents/create-document.ts
index 1c45753a..f7be48b5 100644
--- a/lib/documents/create-document.ts
+++ b/lib/documents/create-document.ts
@@ -13,11 +13,13 @@ export const createDocument = async ({
teamId,
numPages,
folderPathName,
+ createLink = false,
}: {
documentData: DocumentData;
teamId: string;
numPages?: number;
folderPathName?: string;
+ createLink?: boolean;
}) => {
// create a document in the database with the blob url
const response = await fetch(`/api/teams/${teamId}/documents`, {
@@ -33,6 +35,7 @@ export const createDocument = async ({
folderPathName: folderPathName,
type: documentData.supportedFileType,
contentType: documentData.contentType,
+ createLink: createLink,
}),
});
diff --git a/pages/api/teams/[teamId]/documents/index.ts b/pages/api/teams/[teamId]/documents/index.ts
index c2901bfb..627c5579 100644
--- a/pages/api/teams/[teamId]/documents/index.ts
+++ b/pages/api/teams/[teamId]/documents/index.ts
@@ -79,6 +79,7 @@ export default async function handle(
type: fileType,
folderPathName,
contentType,
+ createLink,
} = req.body as {
name: string;
url: string;
@@ -87,6 +88,7 @@ export default async function handle(
type?: string;
folderPathName?: string;
contentType: string;
+ createLink?: boolean;
};
try {
@@ -135,9 +137,11 @@ export default async function handle(
storageType,
ownerId: (session.user as CustomUser).id,
teamId: teamId,
- links: {
- create: {},
- },
+ ...(createLink && {
+ links: {
+ create: {},
+ },
+ }),
versions: {
create: {
file: fileUrl,