mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-19 22:25:51 +02:00
Delete apps/OpenSignServer/package-lock.json
This commit is contained in:
@@ -61,6 +61,7 @@ export default async function saveAsTemplate(request) {
|
||||
status: 'required',
|
||||
response: '',
|
||||
...(p?.options?.defaultValue ? { defaultValue: '' } : {}),
|
||||
...(p?.options?.isReadOnly ? { isReadOnly: false } : {}),
|
||||
},
|
||||
})),
|
||||
}));
|
||||
@@ -89,7 +90,14 @@ export default async function saveAsTemplate(request) {
|
||||
pos: (page.pos || []).map(widget => {
|
||||
// if there is a defaultValue in options, zero it out
|
||||
if (widget.options && widget.options.defaultValue !== undefined) {
|
||||
return { ...widget, options: { ...widget.options, defaultValue: '' } }; // reset only the value
|
||||
return {
|
||||
...widget,
|
||||
options: {
|
||||
...widget.options,
|
||||
defaultValue: '',
|
||||
...(widget?.options?.isReadOnly ? { isReadOnly: false } : {}),
|
||||
},
|
||||
}; // reset only the value
|
||||
}
|
||||
// otherwise, return the widget unchanged
|
||||
return widget;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import axios from 'axios';
|
||||
import { cloudServerUrl, serverAppId } from '../../Utils.js';
|
||||
|
||||
export default async function triggerEvent(request) {
|
||||
const event = request.params.event;
|
||||
const body = request.params.body;
|
||||
const docId = body.objectId;
|
||||
const contactId = request.params.contactId;
|
||||
const serverUrl = cloudServerUrl; //process.env.SERVER_URL;
|
||||
const appId = serverAppId;
|
||||
try {
|
||||
const docQuery = new Parse.Query('contracts_Document');
|
||||
docQuery.select(['Name', 'IsEnableOTP', 'SignedUrl', 'AuditTrail']);
|
||||
const docRes = await docQuery.get(docId, { useMasterKey: true });
|
||||
const _docRes = docRes && docRes?.toJSON();
|
||||
const isEnableOTP = docRes?.get('IsEnableOTP') || false;
|
||||
|
||||
let userId;
|
||||
if (isEnableOTP) {
|
||||
const userRes = await axios.get(serverUrl + '/users/me', {
|
||||
headers: {
|
||||
'X-Parse-Application-Id': appId,
|
||||
'X-Parse-Session-Token': request.headers['sessiontoken'],
|
||||
},
|
||||
});
|
||||
userId = userRes.data && userRes.data.objectId;
|
||||
if (!userId) {
|
||||
return { message: 'User not found!' };
|
||||
}
|
||||
}
|
||||
|
||||
if (event === 'viewed' && contactId) {
|
||||
const auditTrail = Array.isArray(_docRes.AuditTrail) ? _docRes.AuditTrail : [];
|
||||
const isUserExist = auditTrail.some(x => x?.UserPtr?.objectId === contactId && x?.ViewedOn);
|
||||
if (!isUserExist) {
|
||||
const contactPtr = {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Contactbook',
|
||||
objectId: contactId,
|
||||
};
|
||||
|
||||
const date = new Date().toISOString();
|
||||
const newEntry = {
|
||||
UserPtr: contactPtr,
|
||||
SignedUrl: _docRes?.SignedUrl || '',
|
||||
Activity: 'Viewed',
|
||||
ipAddress: request.headers['x-real-ip'],
|
||||
ViewedOn: date,
|
||||
};
|
||||
|
||||
// update Audit trail entry
|
||||
const updateDoc = new Parse.Object('contracts_Document');
|
||||
updateDoc.id = docRes.id;
|
||||
updateDoc.set('AuditTrail', [...auditTrail, newEntry]);
|
||||
await updateDoc.save(null, { useMasterKey: true });
|
||||
}
|
||||
}
|
||||
|
||||
return { message: 'event called!' };
|
||||
} catch (err) {
|
||||
console.log(`Err in triggerEvent: ${err}`);
|
||||
return { message: 'Something went wrong!' };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user