Skip to content

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

feat: add link name to email notification

Marc Seitzdeaa9dfb359b
diff --git a/components/emails/viewed-document.tsx b/components/emails/viewed-document.tsx
index 3efa89f0..052df330 100644
--- a/components/emails/viewed-document.tsx
+++ b/components/emails/viewed-document.tsx
@@ -16,10 +16,12 @@ import {
export default function ViewedDocument({
documentId = "123",
documentName = "Pitchdeck",
+ linkName = "Pitchdeck",
viewerEmail,
}: {
documentId: string;
documentName: string;
+ linkName: string;
viewerEmail: string | null;
}) {
return (
@@ -41,8 +43,8 @@ export default function ViewedDocument({
viewed by{" "}
<span className="font-semibold">
{viewerEmail ? `${viewerEmail}` : `someone`}
- </span>
- .
+ </span>{" "}
+ from the link <span className="font-semibold">{linkName}</span>.
</Text>
<Text className="text-sm leading-6 text-black">
You can get the detailed engagement insights like time-spent per
diff --git a/lib/emails/send-viewed-document.ts b/lib/emails/send-viewed-document.ts
index 3b4b20ab..01c8dfc1 100644
--- a/lib/emails/send-viewed-document.ts
+++ b/lib/emails/send-viewed-document.ts
@@ -6,18 +6,21 @@ export const sendViewedDocumentEmail = async ({
ownerEmail,
documentId,
documentName,
+ linkName,
viewerEmail,
teamMembers,
}: {
ownerEmail: string | null;
documentId: string;
documentName: string;
+ linkName: string;
viewerEmail: string | null;
teamMembers?: string[];
}) => {
const emailTemplate = ViewedDocumentEmail({
documentId,
documentName,
+ linkName,
viewerEmail,
});
try {
diff --git a/pages/api/jobs/send-notification.ts b/pages/api/jobs/send-notification.ts
index 12b094c5..a00aba7c 100644
--- a/pages/api/jobs/send-notification.ts
+++ b/pages/api/jobs/send-notification.ts
@@ -37,6 +37,7 @@ export default async function handle(
viewType: "DOCUMENT_VIEW" | "DATAROOM_VIEW";
viewerEmail: string | null;
linkId: string;
+ link: { name: string | null } | null;
document: {
teamId: string | null;
id: string;
@@ -59,6 +60,11 @@ export default async function handle(
viewType: true,
viewerEmail: true,
linkId: true,
+ link: {
+ select: {
+ name: true,
+ },
+ },
document: {
select: {
teamId: true,
@@ -121,6 +127,7 @@ export default async function handle(
ownerEmail: adminEmail!,
documentId: view.document!.id,
documentName: view.document!.name,
+ linkName: view.link!.name || `Link #${view.linkId.slice(-5)}`,
viewerEmail: view.viewerEmail,
teamMembers: users
.map((user) => user.user.email!)