hubspot issue (#27555)
This commit is contained in:
@@ -560,12 +560,18 @@ class HubspotCalendarService implements CRM {
|
||||
|
||||
const simplePublicObjectInputs = contactsToCreate.map((attendee) => {
|
||||
const [firstname, lastname] = attendee.name ? attendee.name.split(" ") : [attendee.email, ""];
|
||||
const properties: Record<string, string> = {
|
||||
firstname,
|
||||
lastname,
|
||||
email: attendee.email,
|
||||
};
|
||||
|
||||
if (attendee.phone) {
|
||||
properties.phone = attendee.phone;
|
||||
}
|
||||
|
||||
return {
|
||||
properties: {
|
||||
firstname,
|
||||
lastname,
|
||||
email: attendee.email,
|
||||
},
|
||||
properties,
|
||||
};
|
||||
});
|
||||
const createdContacts = await Promise.all(
|
||||
|
||||
@@ -40,8 +40,14 @@ export default class CrmManager {
|
||||
|
||||
if (skipContactCreation) return;
|
||||
const contactSet = new Set(contacts.map((c: { email: string }) => c.email));
|
||||
// Figure out which contacts to create
|
||||
const contactsToCreate = eventAttendees.filter((attendee) => !contactSet.has(attendee.email));
|
||||
// Figure out which contacts to create and map phoneNumber to phone
|
||||
const contactsToCreate: ContactCreateInput[] = eventAttendees
|
||||
.filter((attendee) => !contactSet.has(attendee.email))
|
||||
.map((attendee) => ({
|
||||
email: attendee.email,
|
||||
name: attendee.name,
|
||||
phone: attendee.phoneNumber ?? undefined,
|
||||
}));
|
||||
const createdContacts = await this.createContacts(
|
||||
contactsToCreate,
|
||||
event.organizer?.email,
|
||||
|
||||
Vendored
+1
@@ -11,6 +11,7 @@ export interface CrmData {
|
||||
export interface ContactCreateInput {
|
||||
email: string;
|
||||
name: string;
|
||||
phone?: string | null;
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
|
||||
Reference in New Issue
Block a user