fix: document completion webhook not working in selfsign

This commit is contained in:
prafull-opensignlabs
2024-01-31 13:48:30 +05:30
parent 2d7571af5a
commit 7a5cdefcfa
2 changed files with 21 additions and 15 deletions
+2 -1
View File
@@ -32,7 +32,8 @@ function RemoteApp({ app }) {
width: "100%",
overflow: "hidden",
borderRadius: 3,
minHeight: "70vh"
height: "100%",
minHeight: "100vh"
}}
>
{RemoteComponent && <RemoteComponent />}
+19 -14
View File
@@ -95,15 +95,20 @@ async function sendCompletedMail(e) {
},
});
}
async function sendDoctoWebhook(t) {
var e;
async function sendDoctoWebhook(t, e) {
t.data.ExtUserPtr?.Webhook &&
((e = {
File: t?.data?.SignedUrl,
File: e || '',
Name: t?.data?.Name,
Note: t?.data?.Note,
Description: t?.data?.Description,
Signers: t?.data?.Signers?.map(e => e.Name),
Note: t?.data?.Note || '',
Description: t?.data?.Description || '',
Signers: t?.data?.Signers?.map(e => ({ Name: e.Name, Email: e.Email, Phone: e.Phone })) || [
{
Name: t?.data?.ExtUserPtr?.Name,
Email: t?.data?.ExtUserPtr?.Email,
Phone: t?.data?.ExtUserPtr?.Phone,
},
],
Completed: !0,
CompletedAt: new Date(),
CreatedAt: t?.data?.createdAt,
@@ -217,17 +222,17 @@ async function PDF(i, o) {
(n.data.Signers && 0 < n.data.Signers.length && y.length !== n.data.Signers.length) ||
!(t = !0)
);
var v,
P,
var P,
v,
x = `./exports/exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
b =
(t
? ((v = n.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
? ((P = n.data.Signers?.map(e => e.Name + ' <' + e.Email + '>')),
(e =
v && 0 < v.length
P && 0 < P.length
? plainAddPlaceholder({
pdfBuffer: e,
reason: 'Digitally signed by Open sign for ' + v?.join(', '),
reason: 'Digitally signed by Open sign for ' + P?.join(', '),
location: 'location',
signatureLength: 1e4,
})
@@ -237,8 +242,8 @@ async function PDF(i, o) {
location: 'location',
signatureLength: 1e4,
})),
(P = await new SignPDF(e, u).signPDF()),
fs.writeFileSync(x, P))
(v = await new SignPDF(e, u).signPDF()),
fs.writeFileSync(x, v))
: fs.writeFileSync(x, e),
await uploadFile(x));
if (b && b.imageUrl) {
@@ -265,7 +270,7 @@ async function PDF(i, o) {
pdfName: n.data.Name,
receiver: n.data.ExtUserPtr.Email,
}),
sendDoctoWebhook(n)),
sendDoctoWebhook(n, b.imageUrl)),
fs.unlinkSync(x),
console.log('New Signed PDF created called: ' + x),
'success' === o.message