Skip to content

Commit

Permalink
fix: Function sendScheduledSeatsEmails ignore rule 'Disable default c…
Browse files Browse the repository at this point in the history
…onfirmation emails for attendees' (calcom#11722)
  • Loading branch information
Siddharth-2382 authored Oct 12, 2023
1 parent 2080345 commit 8ebcfbb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
19 changes: 12 additions & 7 deletions packages/emails/email-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<unknown>[] = [];

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);
};

Expand Down
29 changes: 28 additions & 1 deletion packages/features/bookings/lib/handleNewBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8ebcfbb

Please sign in to comment.