diff --git a/packages/emails/email-manager.ts b/packages/emails/email-manager.ts index a97963d16682b6..8a8f5bd799b263 100644 --- a/packages/emails/email-manager.ts +++ b/packages/emails/email-manager.ts @@ -135,20 +135,25 @@ export const sendScheduledSeatsEmails = async ( calEvent: CalendarEvent, invitee: Person, newSeat: boolean, - showAttendees: boolean + showAttendees: boolean, + hostEmailDisabled?: boolean, + attendeeEmailDisabled?: boolean ) => { const emailsToSend: Promise[] = []; - emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent, newSeat }))); + if (!hostEmailDisabled) { + emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent, newSeat }))); - if (calEvent.team) { - for (const teamMember of calEvent.team.members) { - emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent, newSeat, teamMember }))); + if (calEvent.team) { + for (const teamMember of calEvent.team.members) { + emailsToSend.push(sendEmail(() => new OrganizerScheduledEmail({ calEvent, newSeat, teamMember }))); + } } } - emailsToSend.push(sendEmail(() => new AttendeeScheduledEmail(calEvent, invitee, showAttendees))); - + if (!attendeeEmailDisabled) { + emailsToSend.push(sendEmail(() => new AttendeeScheduledEmail(calEvent, invitee, showAttendees))); + } await Promise.all(emailsToSend); }; diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index ee229bb43417c9..005470f8465469 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -1736,8 +1736,35 @@ async function handler( } const copyEvent = cloneDeep(evt); copyEvent.uid = booking.uid; - await sendScheduledSeatsEmails(copyEvent, invitee[0], newSeat, !!eventType.seatsShowAttendees); + if (noEmail !== true) { + let isHostConfirmationEmailsDisabled = false; + let isAttendeeConfirmationEmailDisabled = false; + + const workflows = eventType.workflows.map((workflow) => workflow.workflow); + + if (eventType.workflows) { + isHostConfirmationEmailsDisabled = + eventType.metadata?.disableStandardEmails?.confirmation?.host || false; + isAttendeeConfirmationEmailDisabled = + eventType.metadata?.disableStandardEmails?.confirmation?.attendee || false; + if (isHostConfirmationEmailsDisabled) { + isHostConfirmationEmailsDisabled = allowDisablingHostConfirmationEmails(workflows); + } + + if (isAttendeeConfirmationEmailDisabled) { + isAttendeeConfirmationEmailDisabled = allowDisablingAttendeeConfirmationEmails(workflows); + } + } + await sendScheduledSeatsEmails( + copyEvent, + invitee[0], + newSeat, + !!eventType.seatsShowAttendees, + isHostConfirmationEmailsDisabled, + isAttendeeConfirmationEmailDisabled + ); + } const credentials = await refreshCredentials(allCredentials); const eventManager = new EventManager({ ...organizerUser, credentials }); await eventManager.updateCalendarAttendees(evt, booking);