/claim #16378

Fixes #16378

What does this PR do?

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.

Changes

  1. BookingRepository.ts — Added findBookingAttendeesByUid() to fetch attendee emails and organizer userId from a booking UID.

  2. 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.

  3. slots/util.ts — Added _getGuestAvailabilityForReschedule() method:

    • Host-vs-guest detection: Checks ctx.session.user.email — if no session (guest via email link) or logged-in user is an attendee → skips guest availability check
    • Fetches original booking attendees
    • Looks up if any are registered Cal.com users (via primary OR secondary email)
    • Filters out the host (avoids double-counting)
    • Fetches the guest’s available date ranges
    • Intersects host + guest availability using existing intersect() from date-ranges
    • Non-fatal error handling: if guest lookup fails, falls back to host-only availability
  4. types.ts — Extended ContextForGetSchedule with optional session type for host detection.

  5. Tests (getGuestAvailabilityForReschedule.test.ts) — 331 lines covering:

    • Host-vs-guest distinction: no session → skip, no user email → skip, logged-in attendee → skip, host logged in → proceed
    • Booking not found / empty attendees
    • External (non-Cal.com) attendees
    • Attendee is the host (filtered out)
    • Successful guest availability fetch
    • Multiple attendees (uses first non-host Cal.com user)

How to test

  1. Create two Cal.com users (User A and User B)
  2. User A books User B
  3. User B (host) reschedules → available slots should respect User A’s availability
  4. User A (guest) reschedules via email link → should see all of User B’s available slots (no restriction)
  5. Book with an external email → reschedule works normally

Claim

Total prize pool $200
Total paid $0
Status Pending
Submitted February 25, 2026
Last updated February 25, 2026

Contributors

OP

openclaw12-dev

@openclaw12-dev

100%

Sponsors

CA

Cal.com, Inc.

@cal

$200