Scheduling infrastructure for absolutely everyone.
fix: wrong-event-type-link-for-org-user with same username (#26884)
Dhairyashil Shinded68ae41eedd7
diff --git a/companion/extension/entrypoints/background/index.ts b/companion/extension/entrypoints/background/index.tsindex 08b342c4975..203a6a445e1 100644--- a/companion/extension/entrypoints/background/index.ts+++ b/companion/extension/entrypoints/background/index.ts@@ -947,11 +947,16 @@ async function fetchEventTypes(): Promise<unknown[]> {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.tsindex 21f5230df44..be26d6e4583 100644--- a/companion/services/calcom.ts+++ b/companion/services/calcom.ts@@ -862,21 +862,29 @@ async function getTranscripts(bookingUid: string): Promise<BookingTranscript[]>}async function getEventTypes(): Promise<EventType[]> {- // 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 responseif (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 sortingconst 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.tsindex 7d3b40f7063..0f942f084d8 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<string, unknown>;