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
parent 863e53a2d5
commit 525ff21563
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
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: {