From 137c22962f6e34c9ee6ff993eebeb58c79f2fb4b Mon Sep 17 00:00:00 2001 From: Timur Ercan Date: Mon, 30 Jan 2023 17:33:03 +0100 Subject: [PATCH] singed mail template and fixes --- apps/web/pages/api/documents/[id]/send.ts | 5 +-- packages/lib/mail/sendSignedMail.ts | 43 ++++++++++++++++++++--- packages/lib/mail/sendSigningRequest.ts | 4 +-- 3 files changed, 44 insertions(+), 8 deletions(-) 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}"`, + ` +
+
+ Documenso Logo + ${document.User.name || recipient.email} has signed your document ${ + document.title + }. +

+ + View Document + +

+
+ Click the button to view ${document.title}.
+ If you have questions about this document, your should ask ${ + document.User.name + }. +
+
+ +
+
+ Do not forward. +
+ This email contains a link to a secure document. Keep it secret and do not forward this email. +
+
+ Need help? +
+ Contact us at hi@documenso.com +
+
+ ` ); }; diff --git a/packages/lib/mail/sendSigningRequest.ts b/packages/lib/mail/sendSigningRequest.ts index 559b1350e..33a281790 100644 --- a/packages/lib/mail/sendSigningRequest.ts +++ b/packages/lib/mail/sendSigningRequest.ts @@ -6,7 +6,7 @@ import { NEXT_PUBLIC_WEBAPP_URL } from "../constants"; export const sendSigningRequest = async (recipient: any, document: any) => { // todo errror handling await sendMail( - "timur.ercan31+234234@gmail.com", + document.User.email, `Please sign ${document.title}`, `
@@ -15,7 +15,7 @@ export const sendSigningRequest = async (recipient: any, document: any) => { }"> ${document.User.name} (${document.User.email}) has sent you a document to sign.

- + Sign Document