From 52a5afeba506a40574f7f0efb2851ee017dae803 Mon Sep 17 00:00:00 2001 From: chauhan_s Date: Wed, 1 Oct 2025 14:45:34 +0530 Subject: [PATCH] fix: different calendar hosts (#24000) * fis: pass the missing `platformClientId` to `handleNewBooking` in api/v2 * Update formatCalendarEvent.ts * only add the externald in case of same calendar, otherwise add if from the .ics file sent in email * Revert "fis: pass the missing `platformClientId` to `handleNewBooking` in api/v2" This reverts commit 030ac0f0981c1135d4973fbdafa62d58e8985831. * fix: alow the host change logic to run for collective envets as well * fix: run the changedOrganizer logic for both collective and round-robin events * Update handleNewBooking.ts * fix: failing unit test --------- Co-authored-by: Lauris Skraucis --- .../office365calendar/lib/CalendarService.ts | 4 +++- packages/features/bookings/lib/handleNewBooking.ts | 2 +- ...lective-reschedule-destination-calendar.test.ts | 6 +----- packages/lib/formatCalendarEvent.ts | 14 ++++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.ts index 62219f8769..ba908b1a89 100644 --- a/packages/app-store/office365calendar/lib/CalendarService.ts +++ b/packages/app-store/office365calendar/lib/CalendarService.ts @@ -481,7 +481,9 @@ export default class Office365CalendarService implements Calendar { .map((member) => { const destinationCalendar = event.destinationCalendar && - event.destinationCalendar.find((cal) => cal.userId === member.id); + event.destinationCalendar.find( + (cal) => cal.integration === this.integrationName && cal.userId === member.id + ); return { emailAddress: { address: destinationCalendar?.externalId ?? member.email, diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 7f067f209a..74f08daa95 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1480,7 +1480,7 @@ async function handler( const changedOrganizer = !!originalRescheduledBooking && - eventType.schedulingType === SchedulingType.ROUND_ROBIN && + (eventType.schedulingType === SchedulingType.ROUND_ROBIN || eventType.schedulingType === SchedulingType.COLLECTIVE) && originalRescheduledBooking.userId !== evt.organizer.id; const skipDeleteEventsAndMeetings = changedOrganizer; diff --git a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts index c3cf1b3b94..1a309971ac 100644 --- a/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts +++ b/packages/features/bookings/lib/handleNewBooking/test/team-bookings/collective-reschedule-destination-calendar.test.ts @@ -138,11 +138,7 @@ describe("handleNewBooking", () => { status: BookingStatus.ACCEPTED, startTime: `${plus1DateString}T05:00:00.000Z`, endTime: `${plus1DateString}T05:30:00.000Z`, - users: [ - { - id: 101, // organizer - }, - ], + userId: 101, references: [ { type: appStoreMetadata.dailyvideo.type, diff --git a/packages/lib/formatCalendarEvent.ts b/packages/lib/formatCalendarEvent.ts index a9e8482efe..53d28cb764 100644 --- a/packages/lib/formatCalendarEvent.ts +++ b/packages/lib/formatCalendarEvent.ts @@ -17,10 +17,12 @@ const formatClientIdFromEmails = (calEvent: CalendarEvent | ExtendedCalendarEven const team = calEvent.team ? { ...calEvent.team, - members: calEvent.team.members.map((member) => ({ - ...member, - email: member.email.replace(`+${clientId}`, ""), - })), + members: calEvent.team.members.map((member) => { + return { + ...member, + email: member.email.replace(`+${clientId}`, ""), + }; + }), } : undefined; return [attendees, organizer, team]; @@ -39,8 +41,8 @@ export const formatCalEvent = (calEvent: CalendarEvent) => { export const formatCalEventExtended = (calEvent: ExtendedCalendarEvent) => { const clonedEvent = cloneDeep(calEvent); if (clonedEvent.platformClientId) { - const [attendees, organizer] = formatClientIdFromEmails(clonedEvent, clonedEvent.platformClientId); - Object.assign(clonedEvent, { attendees, organizer }); + const [attendees, organizer, team] = formatClientIdFromEmails(clonedEvent, clonedEvent.platformClientId); + Object.assign(clonedEvent, { attendees, organizer, team }); } return clonedEvent;