When a host reschedules a booking, the system now checks if any attendees (guests) are Cal.com users and fetches their accepted bookings as busy times. This prevents the host from accidentally double-booking a guest during reschedule.
Fixes #16378
/claim #16378
rescheduleUid is present in the slot calculation, look up the booking’s attendeesguestBusyTimes into the availability calculation, where they are merged into detailedBusyTimes| File | Change |
|---|---|
packages/features/users/repositories/UserRepository.ts |
Add findByEmails() — raw SQL UNION matching primary + verified secondary emails, excludes locked accounts |
packages/features/bookings/repositories/BookingRepository.ts |
Add findAcceptedByUserIdsOrEmails() — queries accepted bookings with overlap date semantics |
packages/features/availability/lib/getUserAvailability.ts |
Add guestBusyTimes? to GetUserAvailabilityInitialData; spread into detailedBusyTimes |
packages/trpc/server/routers/viewer/slots/util.ts |
Add getGuestBusyTimesForReschedule() function + call site in calculateHostsAndAvailabilities() |
findVerifiedUsersByEmailsRaw pattern in UserRepository for performance (avoids Prisma OR + secondary email join). No LOWER() on columns to preserve B-tree index usage.startTime <= endDate AND endTime >= startDate to catch bookings that partially overlap the search window, not just those fully contained within it.excludeUid parameter prevents the original booking’s time from being treated as a conflict.guestBusyTimes is an optional field on GetUserAvailabilityInitialData, fully backwards-compatible.select (not include), repository pattern with DI, case-insensitive email matching.getGuestBusyTimesForReschedule (8 tests)BookingRepository.findAcceptedByUserIdsOrEmails (5 tests)UserRepository.findByEmails (3 tests)🤖 Generated with Claude Code
janekissington
@janekissington
Cal.com, Inc.
@cal