Write iCalUID to booking

write-icaluid-to-booking
Joe Au-Yeung 2023-10-26 16:48:42 -04:00
parent b045e996b4
commit 11e1d6fd00
1 changed files with 15 additions and 0 deletions

View File

@ -1099,6 +1099,8 @@ async function handler(
const calEventUserFieldsResponses = const calEventUserFieldsResponses =
"calEventUserFieldsResponses" in reqBody ? reqBody.calEventUserFieldsResponses : null; "calEventUserFieldsResponses" in reqBody ? reqBody.calEventUserFieldsResponses : null;
const iCalUID = `${uid}@cal.com`;
let evt: CalendarEvent = { let evt: CalendarEvent = {
bookerUrl: await getBookerUrl(organizerUser), bookerUrl: await getBookerUrl(organizerUser),
type: eventType.title, type: eventType.title,
@ -1135,6 +1137,7 @@ async function handler(
seatsPerTimeSlot: eventType.seatsPerTimeSlot, seatsPerTimeSlot: eventType.seatsPerTimeSlot,
seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true, seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true,
schedulingType: eventType.schedulingType, schedulingType: eventType.schedulingType,
iCalUID,
}; };
if (isTeamEventType && eventType.schedulingType === "COLLECTIVE") { if (isTeamEventType && eventType.schedulingType === "COLLECTIVE") {
@ -1963,6 +1966,7 @@ async function handler(
connect: { id: evt.destinationCalendar[0].id }, connect: { id: evt.destinationCalendar[0].id },
} }
: undefined, : undefined,
iCalUID: evt.iCalUID,
}; };
if (reqBody.recurringEventId) { if (reqBody.recurringEventId) {
@ -2189,6 +2193,7 @@ async function handler(
); );
} else { } else {
const calendarResult = results.find((result) => result.type.includes("_calendar")); const calendarResult = results.find((result) => result.type.includes("_calendar"));
console.log("🚀 ~ file: handleNewBooking.ts:2195 ~ calendarResult:", calendarResult);
evt.iCalUID = Array.isArray(calendarResult?.updatedEvent) evt.iCalUID = Array.isArray(calendarResult?.updatedEvent)
? calendarResult?.updatedEvent[0]?.iCalUID ? calendarResult?.updatedEvent[0]?.iCalUID
@ -2299,6 +2304,16 @@ async function handler(
evt.appsStatus = handleAppsStatus(results, booking); evt.appsStatus = handleAppsStatus(results, booking);
videoCallUrl = videoCallUrl =
metadata.hangoutLink || organizerOrFirstDynamicGroupMemberDefaultLocationUrl || videoCallUrl; metadata.hangoutLink || organizerOrFirstDynamicGroupMemberDefaultLocationUrl || videoCallUrl;
if (evt.iCalUID !== booking.iCalUID) {
// The eventManager and handleAppsStatus could change the iCalUID. At this point we can update the DB record
await prisma.booking.update({
where: {
booking: booking.id,
},
iCalUID: evt.iCalUID,
});
}
} }
if (noEmail !== true) { if (noEmail !== true) {
let isHostConfirmationEmailsDisabled = false; let isHostConfirmationEmailsDisabled = false;