signinged request template

This commit is contained in:
Timur Ercan
2023-01-30 17:13:02 +01:00
parent 2424134713
commit 55163d4582
8 changed files with 62 additions and 64734 deletions

View File

@ -5,7 +5,7 @@ import {
} from "@documenso/lib/server";
import prisma from "@documenso/prisma";
import { NextApiRequest, NextApiResponse } from "next";
import { sendSigningRequestMail } from "@documenso/lib/mail";
import { sendSigningRequest } from "@documenso/lib/mail";
import { SendStatus } from "@prisma/client";
async function postHandler(req: NextApiRequest, res: NextApiResponse) {
@ -27,6 +27,7 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
User: {
select: {
name: true,
email: true,
},
},
Recipient: true,
@ -41,13 +42,13 @@ async function postHandler(req: NextApiRequest, res: NextApiResponse) {
const recipients = prisma.recipient.findMany({
where: {
documentId: +documentId,
sendStatus: SendStatus.NOT_SENT,
sendStatus: SendStatus.NOT_SENT, // TODO REDO AFTER DEBUG
},
});
// todo check if recipient has an account and show them in their inbox or something
(await recipients).forEach(async (recipient) => {
await sendSigningRequestMail(recipient, document);
await sendSigningRequest(recipient, document);
});
// todo way better error handling

BIN
apps/web/public/logo_h.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

File diff suppressed because one or more lines are too long

View File

@ -1,198 +0,0 @@
%PDF-1.3
%<25><><EFBFBD><EFBFBD>
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Count 2
/Kids [ 4 0 R 6 0 R ]
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/Resources <<
/Font <<
/F1 9 0 R
>>
/ProcSet 8 0 R
>>
/MediaBox [0 0 612.0000 792.0000]
/Contents 5 0 R
>>
endobj
5 0 obj
<< /Length 1074 >>
stream
2 J
BT
0 0 0 rg
/F1 0027 Tf
57.3750 722.2800 Td
( A Simple PDF File ) Tj
ET
BT
/F1 0010 Tf
69.2500 688.6080 Td
( This is a small demonstration .pdf file - ) Tj
ET
BT
/F1 0010 Tf
69.2500 664.7040 Td
( just for use in the Virtual Mechanics tutorials. More text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 652.7520 Td
( text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 628.8480 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 616.8960 Td
( text. And more text. Boring, zzzzz. And more text. And more text. And ) Tj
ET
BT
/F1 0010 Tf
69.2500 604.9440 Td
( more text. And more text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 592.9920 Td
( And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 569.0880 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 557.1360 Td
( text. And more text. And more text. Even more. Continued on page 2 ...) Tj
ET
endstream
endobj
6 0 obj
<<
/Type /Page
/Parent 3 0 R
/Resources <<
/Font <<
/F1 9 0 R
>>
/ProcSet 8 0 R
>>
/MediaBox [0 0 612.0000 792.0000]
/Contents 7 0 R
>>
endobj
7 0 obj
<< /Length 676 >>
stream
2 J
BT
0 0 0 rg
/F1 0027 Tf
57.3750 722.2800 Td
( Simple PDF File 2 ) Tj
ET
BT
/F1 0010 Tf
69.2500 688.6080 Td
( ...continued from page 1. Yet more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 676.6560 Td
( And more text. And more text. And more text. And more text. And more ) Tj
ET
BT
/F1 0010 Tf
69.2500 664.7040 Td
( text. Oh, how boring typing this stuff. But not as boring as watching ) Tj
ET
BT
/F1 0010 Tf
69.2500 652.7520 Td
( paint dry. And more text. And more text. And more text. And more text. ) Tj
ET
BT
/F1 0010 Tf
69.2500 640.8000 Td
( Boring. More, a little more text. The end, and just as well. ) Tj
ET
endstream
endobj
8 0 obj
[/PDF /Text]
endobj
9 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
>>
endobj
10 0 obj
<<
/Creator (Rave \(http://www.nevrona.com/rave\))
/Producer (Nevrona Designs)
/CreationDate (D:20060301072826)
>>
endobj
xref
0 11
0000000000 65535 f
0000000019 00000 n
0000000093 00000 n
0000000147 00000 n
0000000222 00000 n
0000000390 00000 n
0000001522 00000 n
0000001690 00000 n
0000002423 00000 n
0000002456 00000 n
0000002574 00000 n
trailer
<<
/Size 11
/Root 1 0 R
/Info 10 0 R
>>
startxref
2714
%%EOF

View File

@ -1,2 +1,2 @@
export { sendSigningRequest as sendSigningRequestMail } from "./sendSigningRequestMail";
export { sendSigningRequest as sendSigningRequest } from "./sendSigningRequest";
export { sendSignedMail } from "./sendSignedMail";

View File

@ -6,6 +6,6 @@ export const sendSignedMail = async (document: any, recipient: any) => {
await sendMail(
document.user.email,
`${recipient.email} signed ${document.title}`,
`Hi ${document.user.name}, ${recipient.email} has signed your document ${document.title}. Click <a href="${NEXT_PUBLIC_WEBAPP_URL}/document/${document.id}?token=${recipient.token}"> VIEW DOCUMENT</a> to view it now.`
`Hi ${document.user.name}, ${recipient.email} has signed your document ${document.title}. Click <a href="${NEXT_PUBLIC_WEBAPP_URL}/document/${document.id}}"> VIEW DOCUMENT</a> to view it now.`
);
};

View File

@ -0,0 +1,56 @@
import prisma from "@documenso/prisma";
import { sendMail } from "./sendMail";
import { SendStatus, DocumentStatus } from "@prisma/client";
import { NEXT_PUBLIC_WEBAPP_URL } from "../constants";
export const sendSigningRequest = async (recipient: any, document: any) => {
// todo errror handling
await sendMail(
"timur.ercan31+234234@gmail.com",
`Please sign ${document.title} ${NEXT_PUBLIC_WEBAPP_URL}/logo_h.png`,
`
<div style="background-color: #eaeaea; padding: 2%;">
<div style="text-align:center; margin: auto; font-size: 14px; font-color: #353434; max-width: 500px; border-radius: 0.375rem; background: white; padding: 50px">
<img src="${NEXT_PUBLIC_WEBAPP_URL}/logo_h.png" alt="Documenso Logo" style="width: 180px; display: block; margin: auto; margin-bottom: 14px;
}">
${document.User.name} (${document.User.email}) has sent you a document to sign.
<p style="margin: 24px;">
<a href="${NEXT_PUBLIC_WEBAPP_URL}/document/${document.id}/sign?token=${recipient.token}" style="background-color: #37f095; color: white; border-color: transparent; border-width: 1px; border-radius: 0.375rem; font-size: 18px; padding-left: 16px; padding-right: 16px; padding-top: 10px; padding-bottom: 10px; text-decoration: none;">
Sign Document
</a>
</p>
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
Click the button to view and sign ${document.title}.<br>
<small>If you have questions about this document, your should ask ${document.User.name}.</small>
<hr size="1" style="height:1px;border:none;color:#e0e0e0;background-color:#e0e0e0">
</div>
<div style="text-align: left; line-height: 18px; color: #666666; margin: 24px">
<div>
<b>Do not forward.</b>
<br>
This email contains a link to a secure document. Keep it secret and do not forward this email.
</div>
<div style="margin-top: 12px">
<b>Need help?</b>
<br>
Contact us at <a href="mailto:hi@documenso.com">hi@documenso.com</a>
</div>
</div>
`
);
await prisma.recipient.update({
where: {
id: recipient.id,
},
data: { sendStatus: SendStatus.SENT },
});
await prisma.document.update({
where: {
id: document.id,
},
data: { status: DocumentStatus.PENDING },
});
};

View File

@ -1,26 +0,0 @@
import prisma from "@documenso/prisma";
import { sendMail } from "./sendMail";
import { SendStatus, DocumentStatus } from "@prisma/client";
export const sendSigningRequest = async (recipient: any, document: any) => {
// todo errror handling
await sendMail(
recipient.email,
`Please sign ${document.title}`,
`${document.User.name} has sent you a document to sign. Click <b><a href="${process.env.NEXT_PUBLIC_WEBAPP_URL}/documents/${document.id}/sign">SIGN DOCUMENT</a></b> to sign it now.`
);
await prisma.recipient.update({
where: {
id: recipient.id,
},
data: { sendStatus: SendStatus.SENT },
});
await prisma.document.update({
where: {
id: document.id,
},
data: { status: DocumentStatus.PENDING },
});
};