diff --git a/companion/extension/entrypoints/background/index.ts b/companion/extension/entrypoints/background/index.ts index 08b342c497..203a6a445e 100644 --- a/companion/extension/entrypoints/background/index.ts +++ b/companion/extension/entrypoints/background/index.ts @@ -947,11 +947,16 @@ async function fetchEventTypes(): Promise { const userData = await userResponse.json(); const username = userData?.data?.username as string | undefined; + // For org users, include org slug to avoid username collisions across orgs + const orgSlug = userData?.data?.organization?.slug as string | undefined; const params = new URLSearchParams(); if (username) { params.append("username", username); } + if (orgSlug) { + params.append("orgSlug", orgSlug); + } const queryString = params.toString(); const endpoint = `${API_BASE_URL}/event-types${queryString ? `?${queryString}` : ""}`; diff --git a/companion/services/calcom.ts b/companion/services/calcom.ts index 21f5230df4..be26d6e458 100644 --- a/companion/services/calcom.ts +++ b/companion/services/calcom.ts @@ -862,21 +862,29 @@ async function getTranscripts(bookingUid: string): Promise } async function getEventTypes(): Promise { - // Get cached user profile to extract username (uses in-flight deduplication) + // Get cached user profile to extract username and org slug (uses in-flight deduplication) let username: string | undefined; + let orgSlug: string | undefined; try { const userProfile = await getUserProfile(); // Extract username from response if (userProfile?.username) { username = userProfile.username; } + // For org users, include org slug to avoid username collisions across orgs + if (userProfile?.organization?.slug) { + orgSlug = userProfile.organization.slug; + } } catch (_error) {} - // Build query string with username and sorting + // Build query string with username, orgSlug, and sorting const params = new URLSearchParams(); if (username) { params.append("username", username); } + if (orgSlug) { + params.append("orgSlug", orgSlug); + } // Sort by creation date descending (newer first) to match main codebase behavior // Main codebase uses position: "desc", id: "desc" - since API doesn't expose position, // we use sortCreatedAt: "desc" for similar behavior (newer event types first) diff --git a/companion/services/types/users.types.ts b/companion/services/types/users.types.ts index 7d3b40f706..0f942f084d 100644 --- a/companion/services/types/users.types.ts +++ b/companion/services/types/users.types.ts @@ -13,6 +13,8 @@ export interface UserProfile { organizationId?: number; organization?: { id: number; + slug?: string; + name?: string; isPlatform: boolean; }; metadata?: Record;