mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-24 00:22:34 +02:00
Fix: Document title changes are not reflected when the document is sent to signers.
Merge pull request #1498 from nxglabs/staging
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
export default async function updateEmailTemplates(request) {
|
||||
const { tenantId, details } = request.params;
|
||||
|
||||
if (!tenantId || !details) {
|
||||
throw new Parse.Error(400, 'Missing tenantId or details.');
|
||||
}
|
||||
|
||||
if (!request.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'unauthorized');
|
||||
}
|
||||
|
||||
try {
|
||||
const extUser = new Parse.Query('contracts_Users');
|
||||
extUser.equalTo('UserId', { __type: 'Pointer', className: '_User', objectId: request.user.id });
|
||||
extUser.include('TenantId');
|
||||
const extUserRes = await extUser.first({ useMasterKey: true });
|
||||
const mailKeys = ['CompletionBody', 'CompletionSubject', 'RequestBody', 'RequestSubject'];
|
||||
Object.keys(details).forEach(key => {
|
||||
if (mailKeys.includes(key)) {
|
||||
if (details?.[key]) {
|
||||
extUserRes.set(key, details?.[key]);
|
||||
} else {
|
||||
extUserRes.unset(key);
|
||||
}
|
||||
}
|
||||
});
|
||||
const updateExtRes = await extUserRes.save(null, { useMasterKey: true });
|
||||
if (updateExtRes) {
|
||||
const res = JSON.parse(JSON.stringify(updateExtRes));
|
||||
return res;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('error while updating email templates:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user