mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +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 { getDocument } from "@documenso/lib/query";
|
||||||
import { Document as PrismaDocument } from "@prisma/client";
|
import { Document as PrismaDocument } from "@prisma/client";
|
||||||
import { insertImageInPDF, insertTextInPDF } from "@documenso/pdf";
|
import { insertImageInPDF, insertTextInPDF } from "@documenso/pdf";
|
||||||
|
import { sendSigningDoneMail } from "@documenso/lib/mail";
|
||||||
|
|
||||||
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const existingUser = await getUserFromToken(req, res);
|
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();
|
return res.status(200).end();
|
||||||
|
|
||||||
async function insertSignatureInDocument(signedField: any) {
|
async function insertSignatureInDocument(signedField: any) {
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
|
export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
|
||||||
export { sendSignedMail } from "./sendSignedMail";
|
export { sendSigningDoneMail } from "./sendSigningDoneMail";
|
||||||
export { transactionEmailTemplate } from "./transactionEmailTemplate"
|
export { transactionEmailTemplate } from "./transactionEmailTemplate";
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { sendMail } from "./sendMail";
|
|||||||
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
|
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
|
||||||
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
import { transactionEmailTemplate } from "@documenso/lib/mail";
|
||||||
|
|
||||||
export const sendSignedMail = async (
|
export const sendSigningDoneMail = async (
|
||||||
recipient: any,
|
recipient: any,
|
||||||
document: any,
|
document: any,
|
||||||
user: any
|
user: any
|
||||||
@ -12,13 +12,11 @@ export const sendSignedMail = async (
|
|||||||
document.User.email,
|
document.User.email,
|
||||||
`${recipient.email} signed "${document.title}"`,
|
`${recipient.email} signed "${document.title}"`,
|
||||||
transactionEmailTemplate(
|
transactionEmailTemplate(
|
||||||
`${document.User.name || recipient.email} has signed your document ${
|
`All recipients have signed your document ${document.title}`,
|
||||||
document.title
|
|
||||||
}`,
|
|
||||||
document,
|
document,
|
||||||
recipient,
|
recipient,
|
||||||
`${NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}`,
|
`${NEXT_PUBLIC_WEBAPP_URL}/api/documents/${document.id}`,
|
||||||
`View Document`,
|
`Download "${document.title}"`,
|
||||||
user
|
user
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user