On reschedule update sequence

write-icaluid-to-booking
Joe Au-Yeung 2023-10-27 14:59:00 -04:00
parent 757c878200
commit 4813b34feb
2 changed files with 13 additions and 2 deletions

View File

@ -1099,7 +1099,15 @@ async function handler(
const calEventUserFieldsResponses = const calEventUserFieldsResponses =
"calEventUserFieldsResponses" in reqBody ? reqBody.calEventUserFieldsResponses : null; "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 = { let evt: CalendarEvent = {
bookerUrl: await getBookerUrl(organizerUser), bookerUrl: await getBookerUrl(organizerUser),
@ -1138,6 +1146,7 @@ async function handler(
seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true, seatsShowAvailabilityCount: eventType.seatsPerTimeSlot ? eventType.seatsShowAvailabilityCount : true,
schedulingType: eventType.schedulingType, schedulingType: eventType.schedulingType,
iCalUID, iCalUID,
iCalSequence,
}; };
if (isTeamEventType && eventType.schedulingType === "COLLECTIVE") { if (isTeamEventType && eventType.schedulingType === "COLLECTIVE") {
@ -1966,7 +1975,8 @@ async function handler(
connect: { id: evt.destinationCalendar[0].id }, connect: { id: evt.destinationCalendar[0].id },
} }
: undefined, : undefined,
iCalUID: evt.iCalUID, iCalUID: evt.iCalUID ?? "",
iCalSequence: evt.iCalSequence ?? 0,
}; };
if (reqBody.recurringEventId) { if (reqBody.recurringEventId) {

View File

@ -184,6 +184,7 @@ export interface CalendarEvent {
seatsPerTimeSlot?: number | null; seatsPerTimeSlot?: number | null;
schedulingType?: SchedulingType | null; schedulingType?: SchedulingType | null;
iCalUID?: string | null; iCalUID?: string | null;
iCalSequence?: number | null;
// It has responses to all the fields(system + user) // It has responses to all the fields(system + user)
responses?: CalEventResponses | null; responses?: CalEventResponses | null;