mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
Send email notification to signers on document signing completion with signed document
This commit is contained in:
@ -73,6 +73,13 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
},
|
||||
});
|
||||
|
||||
const signedRecipients = await prisma.recipient.findMany({
|
||||
where: {
|
||||
documentId: recipient.documentId,
|
||||
signingStatus: SigningStatus.SIGNED,
|
||||
},
|
||||
});
|
||||
|
||||
// Don't check for inserted, because currently no "sign again" scenarios exist and
|
||||
// this is probably the expected behaviour in unclean states.
|
||||
const nonSignatureFields = await prisma.field.findMany({
|
||||
@ -126,7 +133,11 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
});
|
||||
|
||||
document.document = documentWithInserts;
|
||||
if (documentOwner) await sendSigningDoneMail(recipient, document, documentOwner);
|
||||
if (documentOwner) await sendSigningDoneMail(document, documentOwner);
|
||||
|
||||
for (const signer of signedRecipients) {
|
||||
await sendSigningDoneMail(document, signer);
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(200).end();
|
||||
|
||||
@ -3,7 +3,7 @@ import { addDigitalSignature } from "@documenso/signing/addDigitalSignature";
|
||||
import { sendMail } from "./sendMail";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
|
||||
export const sendSigningDoneMail = async (recipient: any, document: PrismaDocument, user: any) => {
|
||||
export const sendSigningDoneMail = async (document: PrismaDocument, user: any) => {
|
||||
await sendMail(
|
||||
user.email,
|
||||
`Completed: "${document.title}"`,
|
||||
|
||||
Reference in New Issue
Block a user