From 7143923ea451d6e6726d7b5ec6ae75c726dac620 Mon Sep 17 00:00:00 2001 From: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Date: Tue, 5 Sep 2023 23:22:47 +0530 Subject: [PATCH] fix: rescheduling in require confirmation (#11152) ## What does this PR do? Fixes https://github.com/calcom/cal.com/issues/11075 BEFORE: Meeting has been rescheduled email and calendar event after submitting booking without confirming the meeting (require confirmation event type). Screenshot 2023-09-05 at 7 45 44 PM AFTER:- event scheduled email and calendar event created only after "awaiting approval" meeting has been confirmed. Screenshot 2023-09-05 at 7 47 22 PM ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How should this be tested? 1) Create a requires confirmation event type 2) open incognito tab or another browser and book a meeting (Attendee) 3) Confirm the booking (Organizer) and attendee would get meeting schedule email 4) Get the reschedule link from attendee's email and reschedule the booking Both attendee and organiser shouldn't get booking email or calendar event before organiser has accepted the meeting --- .../features/bookings/lib/handleNewBooking.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index 74c92e46ec..0dbd8f4021 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1374,7 +1374,7 @@ async function handler( } } - if (noEmail !== true) { + if (noEmail !== true && (!requiresConfirmation || isOrganizerRescheduling)) { const copyEvent = cloneDeep(evt); await sendRescheduledEmails({ ...copyEvent, @@ -1494,12 +1494,14 @@ async function handler( ? calendarResult?.updatedEvent[0]?.iCalUID : calendarResult?.updatedEvent?.iCalUID || undefined; - // TODO send reschedule emails to attendees of the old booking - await sendRescheduledEmails({ - ...copyEvent, - additionalNotes, // Resets back to the additionalNote input and not the override value - cancellationReason: "$RCH$" + (rescheduleReason ? rescheduleReason : ""), // Removable code prefix to differentiate cancellation from rescheduling for email - }); + if (!requiresConfirmation || isOrganizerRescheduling) { + // TODO send reschedule emails to attendees of the old booking + await sendRescheduledEmails({ + ...copyEvent, + additionalNotes, // Resets back to the additionalNote input and not the override value + cancellationReason: "$RCH$" + (rescheduleReason ? rescheduleReason : ""), // Removable code prefix to differentiate cancellation from rescheduling for email + }); + } // Update the old booking with the cancelled status await prisma.booking.update({ @@ -2097,7 +2099,7 @@ async function handler( videoCallUrl = metadata.hangoutLink || videoCallUrl || updatedEvent?.url; } } - if (noEmail !== true) { + if (noEmail !== true && (!requiresConfirmation || isOrganizerRescheduling)) { const copyEvent = cloneDeep(evt); await sendRescheduledEmails({ ...copyEvent,