Skip to content

fix: handle collective multiple host on destinationCalendar#8

Open
akshayutture-augment wants to merge 1 commit into
enhance-collective-scheduling-foundationfrom
fix/handle-collective-multiple-host-destinations
Open

fix: handle collective multiple host on destinationCalendar#8
akshayutture-augment wants to merge 1 commit into
enhance-collective-scheduling-foundationfrom
fix/handle-collective-multiple-host-destinations

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Copy link
Copy Markdown

Test 4


Replicated from ai-code-review-evaluation/cal.com-cursor#4


Note

Migrate destinationCalendar from single object to array and update core flows and calendar integrations to create/update/delete events per-credential/calendar, with accompanying type and test updates.

  • Core/Event Flow:
    • destinationCalendar now an array across booking creation, cancellation, reminders, confirmations, reschedule, and edits; fallback wraps single values into arrays.
    • Event creation/update deletes iterate over multiple destination calendars; references include externalId and credentialId.
    • Google Meet fallback checks first destination calendar.
  • Integrations:
    • Google Calendar: createEvent(event, credentialId) selects matching calendar by credentialId; organizer attendee email uses selected destination; default to primary if none.
    • Lark / Office365 / CalDAV: Read first destination calendar ([0]) for externalId; list/cal filters consider primary from first.
  • Managers:
    • CalendarManager.createEvent passes credential.id; EventManager creates events per destination, fetching missing credentials from DB; updates handle multiple calendar references.
  • Types:
    • CalendarEvent.destinationCalendar: DestinationCalendar[] | null.
    • Calendar.createEvent(event, credentialId); add schedulingType to CalendarEvent; EventResult gains externalId.
  • Tests/Other:
    • Webhook expectations updated (destinationCalendar: []).
    • Minor fixes (typos/conditional logic, e.g., org slug gating).

Written by Cursor Bugbot for commit bd797c1. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

const selectedCalendar = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.externalId;
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Calendar Selection Fails Without Explicit ID

When externalCalendarId is not provided (null/undefined), the fallback logic attempts to find a calendar where cal.externalId === externalCalendarId, which will never match since it's comparing against a falsy value. This breaks calendar selection when no explicit calendar ID is provided, likely causing events to fail updating on the correct calendar.

Fix in Cursor Fix in Web

const calendarId = externalCalendarId ? externalCalendarId : event.destinationCalendar?.externalId;
const calendarId = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Fallback Logic Fails Calendar Selection

When externalCalendarId is not provided (null/undefined), the fallback logic attempts to find a calendar where cal.externalId === externalCalendarId, which will never match since it's comparing against a falsy value. This breaks calendar selection when no explicit calendar ID is provided, preventing events from being deleted from the correct calendar.

Fix in Cursor Fix in Web

...(IS_TEAM_BILLING_ENABLED ? { slug } : {}),
metadata: {
...(IS_TEAM_BILLING_ENABLED && { requestedSlug: slug }),
...(IS_TEAM_BILLING_ENABLED ? { requestedSlug: slug } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Billing Logic Inverts Organization Slugs

The conditional logic for slug assignment is inverted. When IS_TEAM_BILLING_ENABLED is true, it sets slug directly (should only happen when billing is disabled), and when false, it doesn't set slug (but should). This causes organizations to have incorrect slug configuration based on billing status, breaking organization URL routing.

Fix in Cursor Fix in Web

if (evt.location === MeetLocationType && evt.destinationCalendar?.integration !== "google_calendar") {
// @NOTE: destinationCalendar it's an array now so as a fallback we will only check the first one
const [mainHostDestinationCalendar] = evt.destinationCalendar ?? [];
if (evt.location === MeetLocationType && mainHostDestinationCalendar.integration !== "google_calendar") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Missing Calendar Breaks Event Creation

When evt.destinationCalendar is null, undefined, or empty, mainHostDestinationCalendar becomes undefined. Accessing mainHostDestinationCalendar.integration without optional chaining throws a runtime error when checking if Google Meet fallback is needed. This breaks event creation for bookings without a destination calendar.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants