Skip to content

Commit

Permalink
Merge pull request #1491 from OpenSignLabs/prafull-opensignlabs-patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-opensignlabs authored Nov 28, 2024
2 parents bb80324 + 470ed89 commit 37b41fc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/OpenSignServer/cloud/parsefunction/getSubscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,22 @@ export default async function getSubscription(request) {
} else if (contactId) {
try {
const contactCls = new Parse.Query('contracts_Contactbook');
contactCls.include('CreatedBy');
const contactUser = await contactCls.get(contactId, { useMasterKey: true });
if (contactUser) {
const _contractUser = JSON.parse(JSON.stringify(contactUser));
let TenantId = _contractUser?.TenantId?.objectId || '';
if (!TenantId) {
const extUserCls = new Parse.Query('contracts_Users');
extUserCls.equalTo('Email', _contractUser.CreatedBy.email);
const contactUser = await extUserCls.first({ useMasterKey: true });
TenantId = contactUser?.get('TenantId')?.id || '';
}
const subscriptionCls = new Parse.Query('contracts_Subscriptions');
subscriptionCls.equalTo('TenantId', {
__type: 'Pointer',
className: 'partners_Tenant',
objectId: contactUser.get('TenantId').id,
objectId: TenantId,
});
subscriptionCls.descending('createdAt');
const subcripitions = await subscriptionCls.first({ useMasterKey: true });
Expand Down

0 comments on commit 37b41fc

Please sign in to comment.