Skip to content
  • Sponsor revertinc/revert

  • Notifications You must be signed in to change notification settings
  • Fork 80

Commit 002f116

Browse files
authoredMar 11, 2024··
fix: Return event details upon creation (#512)
1 parent 3c637e4 commit 002f116

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed
 

‎packages/backend/services/crm/contact.ts

+20-13
Original file line numberDiff line numberDiff line change
@@ -832,19 +832,26 @@ const contactService = new ContactService(
832832
authorization: `Zoho-oauthtoken ${thirdPartyToken}`,
833833
},
834834
});
835-
contacts = contacts.data.data;
836-
contacts = await Promise.all(
837-
contacts?.map(
838-
async (l: any) =>
839-
await unifyObject<any, UnifiedContact>({
840-
obj: l,
841-
tpId: thirdPartyId,
842-
objType,
843-
tenantSchemaMappingId: connection.schema_mapping_id,
844-
accountFieldMappingConfig: account.accountFieldMappingConfig,
845-
})
846-
)
847-
);
835+
const isValidContactData =
836+
contacts.data && contacts.data.data !== undefined && Array.isArray(contacts.data.data);
837+
if (isValidContactData) {
838+
contacts = contacts?.data?.data;
839+
840+
contacts = await Promise.all(
841+
contacts?.map(
842+
async (l: any) =>
843+
await unifyObject<any, UnifiedContact>({
844+
obj: l,
845+
tpId: thirdPartyId,
846+
objType,
847+
tenantSchemaMappingId: connection.schema_mapping_id,
848+
accountFieldMappingConfig: account.accountFieldMappingConfig,
849+
})
850+
)
851+
);
852+
} else {
853+
contacts = [];
854+
}
848855
res.send({ status: 'ok', results: contacts });
849856
break;
850857
}

‎packages/backend/services/crm/event.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,19 @@ const eventService = new EventService(
469469
break;
470470
}
471471
case TP_ID.zohocrm: {
472-
await axios({
472+
const eventCreated: any = await axios({
473473
method: 'post',
474474
url: `https://www.zohoapis.com/crm/v3/Events`,
475475
headers: {
476476
authorization: `Zoho-oauthtoken ${thirdPartyToken}`,
477477
},
478478
data: JSON.stringify(event),
479479
});
480-
res.send({ status: 'ok', message: 'Zoho event created', result: event });
480+
res.send({
481+
status: 'ok',
482+
message: 'Zoho event created',
483+
result: { ...event, details: eventCreated.data.data[0].details },
484+
});
481485
break;
482486
}
483487
case TP_ID.sfdc: {

0 commit comments

Comments
 (0)
Please sign in to comment.