/claim #16378
Fixes #16378
When a host reschedules a booking, this PR checks whether any of the attendees (guests/bookers) are registered Cal.com users. If they are, their availability is fetched and intersected with the host’s availability so the reschedule picker only shows time slots that work for both parties.
Important: Guest availability is only checked for host-initiated reschedules. When a guest reschedules themselves (via email link or while logged in as an attendee), they can freely pick any slot on the host’s calendar — per this comment.
BookingRepository.ts — Added findBookingAttendeesByUid() to fetch attendee emails and organizer userId from a booking UID.
UserRepository.ts — Added findUsersByEmailsForAvailability() using raw SQL UNION (matching findVerifiedUsersByEmailsRaw pattern) to check both primary and verified secondary emails. No LOWER() (avoids sequential scan), includes locked = FALSE on both legs.
slots/util.ts — Added _getGuestAvailabilityForReschedule() method:
ctx.session.user.email — if no session (guest via email link) or logged-in user is an attendee → skips guest availability checkintersect() from date-rangestypes.ts — Extended ContextForGetSchedule with optional session type for host detection.
Tests (getGuestAvailabilityForReschedule.test.ts) — 331 lines covering:
openclaw12-dev
@openclaw12-dev
Cal.com, Inc.
@cal