Fix showing seat attendees in emails (#8033)

* Pass seats info to location change

* Fix cloning emails

* Add cloning of event in AttendeeScheduledEmail class
This commit is contained in:
Joe Au-Yeung 2023-03-30 19:45:48 -04:00 committed by GitHub
parent 762810684e
commit ae5425f908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 10 deletions

View File

@ -16,20 +16,18 @@ export default class AttendeeScheduledEmail extends BaseEmail {
attendee: Person;
showAttendees: boolean | undefined;
t: TFunction;
attendees: Person[];
constructor(calEvent: CalendarEvent, attendee: Person, showAttendees?: boolean | undefined) {
super();
this.name = "SEND_BOOKING_CONFIRMATION";
this.calEvent = calEvent;
this.attendee = attendee;
this.showAttendees = showAttendees;
this.t = attendee.language.translate;
this.attendees = [...this.calEvent.attendees];
if (!this.showAttendees && this.calEvent.seatsPerTimeSlot) {
this.attendees = [this.attendee];
this.calEvent.attendees = [this.attendee];
if (!showAttendees && calEvent.seatsPerTimeSlot) {
this.calEvent = cloneDeep(calEvent);
this.calEvent.attendees = [attendee];
} else {
this.calEvent = calEvent;
}
this.name = "SEND_BOOKING_CONFIRMATION";
this.attendee = attendee;
this.t = attendee.language.translate;
}
protected getiCalEventAsString(): string | undefined {

View File

@ -67,6 +67,7 @@ async function getBookingToDelete(id: number | undefined, uid: string | undefine
currency: true,
length: true,
seatsPerTimeSlot: true,
seatsShowAttendees: true,
hosts: {
select: {
user: true,
@ -190,6 +191,8 @@ async function handler(req: CustomRequest) {
destinationCalendar: bookingToDelete?.destinationCalendar || bookingToDelete?.user.destinationCalendar,
cancellationReason: cancellationReason,
...(teamMembers && { team: { name: "", members: teamMembers } }),
seatsPerTimeSlot: bookingToDelete.eventType?.seatsPerTimeSlot,
seatsShowAttendees: bookingToDelete.eventType?.seatsShowAttendees,
};
// If it's just an attendee of a booking then just remove them from that booking

View File

@ -1010,6 +1010,16 @@ async function handler(
throw new HttpError({ statusCode: 401 });
}
// Moving forward in this block is the owner making changes to the booking. All attendees should be affected
evt.attendees = originalRescheduledBooking.attendees.map((attendee) => {
return {
name: attendee.name,
email: attendee.email,
timeZone: attendee.timeZone,
language: { translate: tAttendees, locale: attendee.locale ?? "en" },
};
});
// If owner reschedules the event we want to update the entire booking
// Also if owner is rescheduling there should be no bookingSeat

View File

@ -1032,6 +1032,8 @@ const loggedInViewerRouter = router({
select: {
recurringEvent: true,
title: true,
seatsPerTimeSlot: true,
seatsShowAttendees: true,
},
},
uid: true,
@ -1110,6 +1112,8 @@ const loggedInViewerRouter = router({
location: booking.location,
destinationCalendar: booking.destinationCalendar || booking.user?.destinationCalendar,
cancellationReason: "Payment method removed by organizer",
seatsPerTimeSlot: booking.eventType?.seatsPerTimeSlot,
seatsShowAttendees: booking.eventType?.seatsShowAttendees,
});
}
});

View File

@ -672,6 +672,8 @@ export const bookingsRouter = router({
recurringEvent: parseRecurringEvent(booking.eventType?.recurringEvent),
location,
destinationCalendar: booking?.destinationCalendar || booking?.user?.destinationCalendar,
seatsPerTimeSlot: booking.eventType?.seatsPerTimeSlot,
seatsShowAttendees: booking.eventType?.seatsShowAttendees,
};
const eventManager = new EventManager(ctx.user);