The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
feat: avoid sending pending email to document with 1 recipients
Ephraim Atta-Duncanc58006b2d973
diff --git a/packages/lib/server-only/document/complete-document-with-token.ts b/packages/lib/server-only/document/complete-document-with-token.tsindex ea440beb9..464b7fe4f 100644--- a/packages/lib/server-only/document/complete-document-with-token.ts+++ b/packages/lib/server-only/document/complete-document-with-token.ts@@ -70,8 +70,15 @@ export const completeDocumentWithToken = async ({},});- // TODO: Send email to documents with two or more recipients- await sendPendingEmail({ documentId, recipientId: recipient.id });+ const numberOfRecipients = await prisma.recipient.count({+ where: {+ documentId: document.id,+ },+ });++ if (numberOfRecipients > 1) {+ await sendPendingEmail({ documentId, recipientId: recipient.id });+ }const documents = await prisma.document.updateMany({where: {diff --git a/packages/lib/server-only/document/send-completed-email.ts b/packages/lib/server-only/document/send-completed-email.tsindex b8d50dba4..0a1817964 100644--- a/packages/lib/server-only/document/send-completed-email.ts+++ b/packages/lib/server-only/document/send-completed-email.ts@@ -48,7 +48,7 @@ export const sendCompletedEmail = async ({ documentId }: SendDocumentOptions) =>name: process.env.NEXT_PRIVATE_SMTP_FROM_NAME || 'Documenso',address: process.env.NEXT_PRIVATE_SMTP_FROM_ADDRESS || '[email protected]',},- subject: 'Everyone has signed!',+ subject: 'Signing Complete!',html: render(template),text: render(template, { plainText: true }),});