mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
🚧 send signed notifcations
This commit is contained in:
@ -9,6 +9,7 @@ import { SigningStatus, DocumentStatus } from "@prisma/client";
|
||||
import { getDocument } from "@documenso/lib/query";
|
||||
import { Document as PrismaDocument } from "@prisma/client";
|
||||
import { insertImageInPDF, insertTextInPDF } from "@documenso/pdf";
|
||||
import { sendSigningDoneMail } from "@documenso/lib/mail";
|
||||
|
||||
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const existingUser = await getUserFromToken(req, res);
|
||||
@ -83,6 +84,15 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||
},
|
||||
});
|
||||
|
||||
if (unsignedRecipients.length === 0) {
|
||||
const documentOwner = await prisma.user.findFirstOrThrow({
|
||||
where: { id: document.userId },
|
||||
select: { email: true, name: true },
|
||||
});
|
||||
|
||||
if (documentOwner) sendSigningDoneMail(recipient, document, documentOwner);
|
||||
}
|
||||
|
||||
return res.status(200).end();
|
||||
|
||||
async function insertSignatureInDocument(signedField: any) {
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
|
||||
export { sendSignedMail } from "./sendSignedMail";
|
||||
export { transactionEmailTemplate } from "./transactionEmailTemplate"
|
||||
export { sendSigningDoneMail } from "./sendSigningDoneMail";
|
||||
export { transactionEmailTemplate } from "./transactionEmailTemplate";
|
||||
|
||||
@ -2,7 +2,7 @@ import { sendMail } from "./sendMail";
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
|
||||
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
||||
|
||||
export const sendSignedMail = async (
|
||||
export const sendSigningDoneMail = async (
|
||||
recipient: any,
|
||||
document: any,
|
||||
user: any
|
||||
@ -12,13 +12,11 @@ export const sendSignedMail = async (
|
||||
document.User.email,
|
||||
`${recipient.email} signed "${document.title}"`,
|
||||
transactionEmailTemplate(
|
||||
`${document.User.name || recipient.email} has signed your document ${
|
||||
document.title
|
||||
}`,
|
||||
`All recipients have signed your document ${document.title}`,
|
||||
document,
|
||||
recipient,
|
||||
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}`,
|
||||
`View Document`,
|
||||
`${NEXT_PUBLIC_WEBAPP_URL}/api/documents/${document.id}`,
|
||||
`Download "${document.title}"`,
|
||||
user
|
||||
)
|
||||
);
|
||||
Reference in New Issue
Block a user