feat: add emailcount of user

This commit is contained in:
prafull-opensignlabs
2024-03-31 12:42:08 +05:30
parent d588caf6d4
commit 5adaffc684
14 changed files with 126 additions and 102 deletions
+32 -29
View File
@@ -48,10 +48,12 @@ async function sendCompletedMail(e) {
var a = e.url,
t = e.sender,
s = e.pdfName,
a = {
r = e.receiver,
e = {
extUserId: e.extUserId,
url: a,
from: 'OpenSign™',
recipient: e.receiver,
recipient: r,
subject: `Document ${s} has been signed by all parties`,
pdfName: s,
html:
@@ -61,7 +63,7 @@ async function sendCompletedMail(e) {
t.Mail +
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
};
await axios.post(serverUrl + '/functions/sendmailv3', a, {
await axios.post(serverUrl + '/functions/sendmailv3', e, {
headers: {
'Content-Type': 'application/json',
'X-Parse-Application-Id': APPID,
@@ -206,11 +208,11 @@ async function PDF(i) {
var P,
y,
v,
b,
U,
b,
I,
S = `exported_file_${Math.floor(5e3 * Math.random())}.pdf`,
A = './exports/' + S;
x = './exports/' + S;
let s = e.length;
s = (
t
@@ -226,51 +228,52 @@ async function PDF(i) {
}),
(v = await y.save()),
Buffer.from(v))
: ((b = await PDFDocument.load(e)),
: ((U = await PDFDocument.load(e)),
pdflibAddPlaceholder({
pdfDoc: b,
pdfDoc: U,
reason: 'Digitally signed by OpenSign for ' + p + ' <' + m + '>',
location: 'location',
signatureLength: 15e3,
}),
(U = await b.save()),
Buffer.from(U))),
(b = await U.save()),
Buffer.from(b))),
(I = await new SignPDF(e, u).signPDF()),
fs.writeFileSync(A, I),
fs.writeFileSync(x, I),
I)
: (fs.writeFileSync(A, e), e)
: (fs.writeFileSync(x, e), e)
).length;
var w,
D,
x = await uploadFile(S, A);
if (x && x.imageUrl)
var A,
w,
D = await uploadFile(S, x);
if (D && D.imageUrl)
return (
(w = await updateDoc(
(A = await updateDoc(
i.params.docId,
x.imageUrl,
D.imageUrl,
r.data.results[0].objectId,
i.headers['x-real-ip'],
n.data,
o
)),
sendDoctoWebhook(n, x.imageUrl, 'signed', r?.data.results?.[0]),
saveFileUsage(s, x.imageUrl, d.data.objectId),
w &&
w.isCompleted &&
((D = {
url: x.imageUrl,
sendDoctoWebhook(n, D.imageUrl, 'signed', r?.data.results?.[0]),
saveFileUsage(s, D.imageUrl, d.data.objectId),
A &&
A.isCompleted &&
((w = {
url: D.imageUrl,
sender: { Mail: n.data.ExtUserPtr.Email, Name: 'OpenSign™' },
pdfName: n.data.Name,
receiver: n.data.ExtUserPtr.Email,
extUserId: n.data.ExtUserPtr.objectId,
}),
n.data.IsSendMail && !1 === n.data.IsSendMail
? console.log("don't send mail")
: sendCompletedMail(D),
sendDoctoWebhook(n, x.imageUrl, 'completed')),
fs.unlinkSync(A),
console.log('New Signed PDF created called: ' + A),
'success' === w.message
? { status: 'success', data: x.imageUrl }
: sendCompletedMail(w),
sendDoctoWebhook(n, D.imageUrl, 'completed')),
fs.unlinkSync(x),
console.log('New Signed PDF created called: ' + x),
'success' === A.message
? { status: 'success', data: D.imageUrl }
: { status: 'error', message: 'please provide required parameters!' }
);
}