Skip to content

Commit e82bd45

Browse files
fix: Incorrect RR host is shown in the email and calendar event for a seated RR event (calcom#21684)
* fix: seated rr event * Update packages/features/bookings/lib/handleNewBooking.ts Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * update * Update handleNewBooking.ts --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent 13966e0 commit e82bd45

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

packages/features/bookings/lib/handleNewBooking.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,31 @@ async function handler(
650650
startTime: new Date(dayjs(reqBody.start).utc().format()),
651651
status: BookingStatus.ACCEPTED,
652652
},
653+
select: {
654+
userId: true,
655+
attendees: { select: { email: true } },
656+
},
653657
});
654658

655-
if (booking) isFirstSeat = false;
659+
if (booking) {
660+
isFirstSeat = false;
661+
if (eventType.schedulingType === SchedulingType.ROUND_ROBIN) {
662+
const fixedHosts = users.filter((user) => user.isFixed);
663+
const originalNonFixedHost = users.find((user) => !user.isFixed && user.id === booking.userId);
664+
665+
if (originalNonFixedHost) {
666+
users = [...fixedHosts, originalNonFixedHost];
667+
} else {
668+
const attendeeEmailSet = new Set(booking.attendees.map((attendee) => attendee.email));
669+
670+
// In this case, the first booking user is a fixed host, so the chosen non-fixed host is added as an attendee of the booking
671+
const nonFixedAttendeeHost = users.find(
672+
(user) => !user.isFixed && attendeeEmailSet.has(user.email)
673+
);
674+
users = [...fixedHosts, ...(nonFixedAttendeeHost ? [nonFixedAttendeeHost] : [])];
675+
}
676+
}
677+
}
656678
}
657679

658680
//checks what users are available

0 commit comments

Comments
 (0)