feat: avoid sending pending email to document with 1 recipients

This commit is contained in:
Ephraim Atta-Duncan
2023-09-07 20:52:18 +00:00
committed by Mythie
parent f18010e1e1
commit c58006b2d9
2 changed files with 10 additions and 3 deletions

View File

@ -70,8 +70,15 @@ export const completeDocumentWithToken = async ({
},
});
// TODO: Send email to documents with two or more recipients
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: {

View File

@ -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 || 'noreply@documenso.com',
},
subject: 'Everyone has signed!',
subject: 'Signing Complete!',
html: render(template),
text: render(template, { plainText: true }),
});