Scheduling infrastructure for absolutely everyone.
Fix showing seat attendees in emails (#8033)
Joe Au-Yeungae5425f908fe
diff --git a/packages/emails/templates/attendee-scheduled-email.ts b/packages/emails/templates/attendee-scheduled-email.tsindex a887c4bd055..46ed34cca63 100644--- a/packages/emails/templates/attendee-scheduled-email.ts+++ b/packages/emails/templates/attendee-scheduled-email.ts@@ -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();+ if (!showAttendees && calEvent.seatsPerTimeSlot) {+ this.calEvent = cloneDeep(calEvent);+ this.calEvent.attendees = [attendee];+ } else {+ this.calEvent = calEvent;+ }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];- }}protected getiCalEventAsString(): string | undefined {diff --git a/packages/features/bookings/lib/handleCancelBooking.ts b/packages/features/bookings/lib/handleCancelBooking.tsindex cea53d5ed1f..ce8dd6dcf80 100644--- a/packages/features/bookings/lib/handleCancelBooking.ts+++ b/packages/features/bookings/lib/handleCancelBooking.ts@@ -67,6 +67,7 @@ async function getBookingToDelete(id: number | undefined, uid: string | undefinecurrency: 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 bookingdiff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.tsindex b7bf5d0c5a0..0459622fe4c 100644--- a/packages/features/bookings/lib/handleNewBooking.ts+++ b/packages/features/bookings/lib/handleNewBooking.ts@@ -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 bookingSeatdiff --git a/packages/trpc/server/routers/viewer.tsx b/packages/trpc/server/routers/viewer.tsxindex 152a9d16bf2..2448847d19a 100644--- a/packages/trpc/server/routers/viewer.tsx+++ b/packages/trpc/server/routers/viewer.tsx@@ -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,});}});diff --git a/packages/trpc/server/routers/viewer/bookings.tsx b/packages/trpc/server/routers/viewer/bookings.tsxindex ed8bd8d5e05..914cec161a3 100644--- a/packages/trpc/server/routers/viewer/bookings.tsx+++ b/packages/trpc/server/routers/viewer/bookings.tsx@@ -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);