diff --git a/apps/web/pages/api/documents/[id]/send.ts b/apps/web/pages/api/documents/[id]/send.ts index e188a6b24..455a8c740 100644 --- a/apps/web/pages/api/documents/[id]/send.ts +++ b/apps/web/pages/api/documents/[id]/send.ts @@ -5,7 +5,7 @@ import { } from "@documenso/lib/server"; import prisma from "@documenso/prisma"; import { NextApiRequest, NextApiResponse } from "next"; -import { sendSigningRequest } from "@documenso/lib/mail"; +import { sendSignedMail, sendSigningRequest } from "@documenso/lib/mail"; import { SendStatus } from "@prisma/client"; async function postHandler(req: NextApiRequest, res: NextApiResponse) { @@ -42,13 +42,14 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) { const recipients = prisma.recipient.findMany({ where: { documentId: +documentId, - sendStatus: SendStatus.NOT_SENT, // TODO REDO AFTER DEBUG + // sendStatus: SendStatus.NOT_SENT, // TODO REDO AFTER DEBUG }, }); // todo check if recipient has an account and show them in their inbox or something (await recipients).forEach(async (recipient) => { await sendSigningRequest(recipient, document); + await sendSignedMail(recipient, document); }); // todo way better error handling diff --git a/packages/lib/mail/sendSignedMail.ts b/packages/lib/mail/sendSignedMail.ts index d6757b186..82fdb2aa1 100644 --- a/packages/lib/mail/sendSignedMail.ts +++ b/packages/lib/mail/sendSignedMail.ts @@ -1,11 +1,46 @@ import { sendMail } from "./sendMail"; import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants"; -export const sendSignedMail = async (document: any, recipient: any) => { +export const sendSignedMail = async (recipient: any, document: any) => { // todo check if recipient has an account await sendMail( - document.user.email, - `${recipient.email} signed ${document.title}`, - `Hi ${document.user.name}, ${recipient.email} has signed your document ${document.title}. Click VIEW DOCUMENT to view it now.` + document.User.email, + `${recipient.email} signed "${document.title}"`, + ` +
+ ${document.User.name || recipient.email} has signed your document ${
+ document.title
+ }.
+
+