This commit is contained in:
Raktima
2026-05-22 21:03:28 +05:30
committed by GitHub
parent b9a309fa36
commit 1e228c86c3
92 changed files with 8705 additions and 5397 deletions
@@ -1,13 +1,5 @@
import axios from 'axios';
import { appName, cloudServerUrl, serverAppId } from '../../Utils.js';
const serverUrl = cloudServerUrl;
const APPID = serverAppId;
const masterKEY = process.env.MASTER_KEY;
const headers = {
'Content-Type': 'application/json',
'X-Parse-Application-Id': APPID,
'X-Parse-Master-Key': masterKEY,
};
import { appName } from '../../Utils.js';
import sendSystemMail from './sendSystemMail.js';
async function sendDeclineMail(doc, publicUrl, userId, reason) {
try {
@@ -46,7 +38,7 @@ async function sendDeclineMail(doc, publicUrl, userId, reason) {
pdfName: pdfName,
html: body,
};
await axios.post(serverUrl + '/functions/sendmailv3', params, { headers });
await sendSystemMail({ params });
} catch (err) {
console.log('err in sendnotifymail', err);
}
@@ -63,16 +55,21 @@ export default async function declinedocument(request) {
try {
const docCls = new Parse.Query('contracts_Document');
docCls.include('ExtUserPtr.TenantId,Placeholders.signerPtr,Signers');
docCls.notEqualTo('IsCompleted', true);
docCls.notEqualTo('IsArchive', true);
const updateDoc = await docCls.get(docId, { useMasterKey: true });
if (updateDoc) {
const _doc = JSON.parse(JSON.stringify(updateDoc));
const isEnableOTP = updateDoc?.get('IsEnableOTP') || false;
const isCreator = _doc?.CreatedBy?.objectId === userId;
if (!isEnableOTP) {
updateDoc.set('IsDeclined', true);
updateDoc.set('DeclineReason', reason);
updateDoc.set('DeclineBy', declineBy);
await updateDoc.save(null, { useMasterKey: true });
sendDeclineMail(_doc, publicUrl, userId, reason);
if (!isCreator) {
sendDeclineMail(_doc, publicUrl, userId, reason);
}
return 'document declined';
} else {
if (!request?.user) {
@@ -82,7 +79,10 @@ export default async function declinedocument(request) {
updateDoc.set('DeclineReason', reason);
updateDoc.set('DeclineBy', declineBy);
await updateDoc.save(null, { useMasterKey: true });
sendDeclineMail(_doc, publicUrl, userId, reason);
const isCreator = _doc?.CreatedBy?.objectId === request?.user?.id;
if (!isCreator) {
sendDeclineMail(_doc, publicUrl, userId, reason);
}
return 'document declined';
}
} else {