From 49ee5d300b0edf6da49a5748bc6aa0d38b66ffc4 Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Wed, 22 Mar 2023 10:23:09 -0400 Subject: [PATCH] Fix rescheduling updating calendars & duplicate bookings (#7851) * Fix rescheduling * Fix tests * Clean up * Update packages/core/EventManager.ts Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> * Commit fix --------- Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: Peer Richelsen --- packages/core/EventManager.ts | 9 +++------ packages/features/bookings/lib/handleNewBooking.ts | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/core/EventManager.ts b/packages/core/EventManager.ts index 845db40562..29e4cae4c3 100644 --- a/packages/core/EventManager.ts +++ b/packages/core/EventManager.ts @@ -439,12 +439,9 @@ export default class EventManager { }); } - if (newBooking) { - calendarReference = newBooking.references.find((reference) => reference.type.includes("_calendar")); - } else { - // Bookings should only have one calendar reference - calendarReference = booking.references.find((reference) => reference.type.includes("_calendar")); - } + calendarReference = newBooking?.references.length + ? newBooking.references.find((reference) => reference.type.includes("_calendar")) + : booking.references.find((reference) => reference.type.includes("_calendar")); if (!calendarReference) { return []; diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 4f6beb8a77..68f8ffab76 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1655,7 +1655,7 @@ async function handler( // Use EventManager to conditionally use all needed integrations. - const updateManager = await eventManager.reschedule(evt, originalRescheduledBooking.uid, booking?.id); + const updateManager = await eventManager.reschedule(evt, originalRescheduledBooking.uid); // This gets overridden when updating the event - to check if notes have been hidden or not. We just reset this back // to the default description when we are sending the emails. evt.description = eventType.description;