Skip to content

feat: add integration options for API v2 update booking location endpoint#26363

Merged
Ryukemeister merged 83 commits intomainfrom
rajiv/cal-6964-api-v2-add-integration-options-for-update-booking-location
Mar 17, 2026
Merged

feat: add integration options for API v2 update booking location endpoint#26363
Ryukemeister merged 83 commits intomainfrom
rajiv/cal-6964-api-v2-add-integration-options-for-update-booking-location

Conversation

@Ryukemeister
Copy link
Contributor

@Ryukemeister Ryukemeister commented Jan 1, 2026

What does this PR do?

Adds support for integration-based locations (video conferencing) to the API v2 Update Booking Location endpoint, addressing CAL-6964.

  • Fixes CAL-6964

New Features

  • Integration location type: Users can now update a booking's location to any supported video integration (Cal Video, Google Meet, MS Teams, Zoom, Webex, etc.)
  • Automatic video meeting creation: When updating to an integration location, the API automatically creates the video meeting and stores the meeting URL
  • Calendar sync: Updates the calendar event with the new location/meeting link for all connected calendars
  • Cleanup of old meetings: Automatically deletes old video meetings when switching to a new integration or non-integration location
  • Location change notifications: Sends email and SMS notifications to attendees when the booking location changes
  • Rate limiting: Added throttle on the location update endpoint (5 requests / 60s)

Technical Changes

  • BookingLocationService_2024_08_13: Added integration routing and specialized handlers for each integration type with smart fallback logic (e.g., Google Meet without Google Calendar falls back to Cal Video)
  • BookingLocationIntegrationService_2024_08_13, BookingLocationCalendarSyncService_2024_08_13, BookingLocationCredentialService_2024_08_13, BookingVideoService_2024_08_13: New service classes split out for integration handling, calendar sync, credential resolution, and video operations
  • BookingsRepository_2024_08_13: Added getBookingByUidWithUserAndEventDetails and getBookingByIdWithUserAndEventDetails methods
  • UpdateBookingLocationInput_2024_08_13: Added UpdateBookingInputIntegrationLocation_2024_08_13 to the input schema with Swagger docs
  • bookingWithUserAndEventDetailsSelect: New shared Prisma select added to packages/prisma/selects/booking.ts
  • packages/platform/libraries: Exported updateEvent, CredentialRepository, BookingReferenceRepository, buildCalEventFromBooking, sendLocationChangeEmailsAndSMS, and other utilities needed by the integration services

E2E Tests (added per review feedback)

  • Cal Video: Verifies location updates to cal-video integration
  • Google Meet: Creates a booking with a google_calendar BookingReference + credential, mocks updateEvent returning a hangoutLink, asserts the location is the Google Meet URL
  • Microsoft Teams: Creates a booking with an office365_calendar BookingReference + credential, mocks updateEvent returning a url, asserts the location is the MS Teams URL
  • Mocks @calcom/platform-libraries (updateEvent, CredentialRepository.findCredentialForCalendarServiceById, sendLocationChangeEmailsAndSMS) and @calcom/platform-libraries/conferencing (createMeeting)

API Usage Example

PATCH /v2/bookings/{uid}/location
{
  "location": {
    "type": "integration",
    "integration": "google-meet"
  }
}

Updates since last revision

Code simplification pass across the service layer for improved readability:

  • booking-location-credential.service.ts: Extracted resolveCredentialId() private method — replaces nested if/else with early returns for cleaner credential ID resolution logic
  • booking-location-integration.service.ts: Removed redundant explicit type annotations on .references callbacks (TS infers them). Extracted buildUpdatedMetadata() and emitLocationChangeEvents() helpers to eliminate duplicated audit + notification code across handleCalendarBasedIntegration() and updateBookingWithVideoLocation()
  • booking-location.service.ts: Extracted sendLocationChangeNotifications() helper with early-return guard clauses. Consolidated duplicate BookingForLocationUpdate type — now defined once in booking-location-integration.service.ts and imported here

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A — endpoint behavior documented via Swagger decorators.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Unit/E2E tests: Run TZ=UTC yarn test apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/update-booking-location.e2e-spec.ts
  2. Manual testing:
    • Create a booking via API v2
    • PATCH /v2/bookings/{uid}/location with { "location": { "type": "integration", "integration": "cal-video" } }
    • Verify the booking location is updated to a Daily video URL
    • For Google Meet/MS Teams, ensure the user has the respective calendar connected

Human Review Checklist

  • Verify the updateEvent mock logic (evt.conferenceData?.createRequest for Google Meet detection) matches the actual service implementation in booking-location-integration.service.ts
  • Confirm test cleanup runs correctly even if assertions fail (tests clean up inline, not in afterAll)
  • Verify CI passes for the new e2e tests
  • Check that the throttle decorator (5 req/60s) is appropriate for this endpoint
  • Verify the extracted resolveCredentialId() method in credential service preserves the original priority order (delegationCredentialId → credentialId → type match)
  • Confirm emitLocationChangeEvents() correctly handles the audit + notification flow for both calendar-based and direct video integrations

Link to Devin run: https://app.devin.ai/sessions/eaca73aee7084c4b9895341aa000cfcf
Requested by: @Ryukemeister

@linear
Copy link

linear bot commented Jan 1, 2026

@vercel
Copy link

vercel bot commented Jan 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Review Updated (UTC)
cal Ignored Ignored Jan 6, 2026 1:02pm
cal-companion Ignored Ignored Preview Jan 6, 2026 1:02pm
cal-eu Ignored Ignored Jan 6, 2026 1:02pm

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jan 6, 2026
@keithwillcode keithwillcode added the core area: core, team members only label Jan 10, 2026
@vercel vercel bot temporarily deployed to Preview – cal-companion January 13, 2026 08:10 Inactive
@vercel vercel bot temporarily deployed to Preview – dev January 13, 2026 08:10 Inactive
@github-actions
Copy link
Contributor

Devin AI is resolving merge conflicts

This PR has merge conflicts with the main branch. A Devin session has been created to automatically resolve them.

View Devin Session

Devin will:

  1. Merge the latest main into this branch
  2. Resolve any conflicts intelligently
  3. Run lint/type checks to ensure validity
  4. Push the resolved changes

If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself.

…s-for-update-booking-location

Co-Authored-By: unknown <>
@Ryukemeister Ryukemeister removed ready-for-e2e run-ci Approve CI to run for external contributors labels Mar 6, 2026
@Ryukemeister Ryukemeister added ready-for-e2e run-ci Approve CI to run for external contributors labels Mar 6, 2026
@CarinaWolli CarinaWolli modified the milestones: v6.3, v6.4 Mar 16, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/update-booking-location.e2e-spec.ts">

<violation number="1" location="apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/update-booking-location.e2e-spec.ts:519">
P2: This fallback test is too weak to prove the booking switched to Cal Video; it would still pass for other integration URLs.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

…Daily URL

Replace weak assertion that would pass for any HTTP URL with a strict
check against the known Cal Video mock values (integrations:daily and
the mock Daily URL). This ensures the test actually proves the booking
fell back to Cal Video rather than any other integration.

Addresses Cubic AI review feedback (confidence 9/10).

Co-Authored-By: bot_apk <apk@cognition.ai>
@Ryukemeister Ryukemeister merged commit 089a39f into main Mar 17, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

consumer core area: core, team members only ready-for-e2e run-ci Approve CI to run for external contributors size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants