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;