From 4813b34febb0801f2a2629ad7b4589511eac2f6f Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung Date: Fri, 27 Oct 2023 14:59:00 -0400 Subject: [PATCH] On reschedule update sequence --- packages/features/bookings/lib/handleNewBooking.ts | 14 ++++++++++++-- packages/types/Calendar.d.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 884ee75d94..c873b65f6a 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1099,7 +1099,15 @@ async function handler( const calEventUserFieldsResponses = "calEventUserFieldsResponses" in reqBody ? reqBody.calEventUserFieldsResponses : null; - const iCalUID = rescheduleUid ? originalRescheduledBooking?.iCalUID : `${uid}@cal.com`; + const iCalUID = originalRescheduledBooking?.iCalUID ?? `${uid}@cal.com`; + // For bookings made before introducing iCalSequence, assume that the sequence should start at 1. For new bookings start at 0. + const iCalSequence = originalRescheduledBooking?.iCalSequence + ? originalRescheduledBooking.iCalSequence + 1 + : originalRescheduledBooking + ? 1 + : 0; + + console.log("🚀 ~ file: handleNewBooking.ts:1105 ~ iCalSequence:", iCalSequence); let evt: CalendarEvent = { bookerUrl: await getBookerUrl(organizerUser), @@ -1138,6 +1146,7 @@ async function handler( seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true, schedulingType: eventType.schedulingType, iCalUID, + iCalSequence, }; if (isTeamEventType && eventType.schedulingType === "COLLECTIVE") { @@ -1966,7 +1975,8 @@ async function handler( connect: { id: evt.destinationCalendar[0].id }, } : undefined, - iCalUID: evt.iCalUID, + iCalUID: evt.iCalUID ?? "", + iCalSequence: evt.iCalSequence ?? 0, }; if (reqBody.recurringEventId) { diff --git a/packages/types/Calendar.d.ts b/packages/types/Calendar.d.ts index b8e3989f71..57e04ea41f 100644 --- a/packages/types/Calendar.d.ts +++ b/packages/types/Calendar.d.ts @@ -184,6 +184,7 @@ export interface CalendarEvent { seatsPerTimeSlot?: number | null; schedulingType?: SchedulingType | null; iCalUID?: string | null; + iCalSequence?: number | null; // It has responses to all the fields(system + user) responses?: CalEventResponses | null;