diff --git a/companion/extension/entrypoints/background/index.ts b/companion/extension/entrypoints/background/index.ts index 203a6a445e..db4af166fa 100644 --- a/companion/extension/entrypoints/background/index.ts +++ b/companion/extension/entrypoints/background/index.ts @@ -933,34 +933,9 @@ async function getAuthHeader(): Promise { async function fetchEventTypes(): Promise { const authHeader = await getAuthHeader(); - const userResponse = await fetchWithTimeout(`${API_BASE_URL}/me`, { - headers: { - Authorization: authHeader, - "Content-Type": "application/json", - "cal-api-version": "2024-06-11", - }, - }); - - if (!userResponse.ok) { - throw new Error(`Failed to get user: ${userResponse.statusText}`); - } - - 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}` : ""}`; - - const response = await fetchWithTimeout(endpoint, { + // For authenticated users, no username/orgSlug params needed - API uses auth token + // This also ensures hidden event types are returned (they're filtered out when username is provided) + const response = await fetchWithTimeout(`${API_BASE_URL}/event-types`, { headers: { Authorization: authHeader, "Content-Type": "application/json", diff --git a/companion/services/calcom.ts b/companion/services/calcom.ts index be26d6e458..422233c13a 100644 --- a/companion/services/calcom.ts +++ b/companion/services/calcom.ts @@ -862,36 +862,10 @@ async function getTranscripts(bookingUid: string): Promise } async function getEventTypes(): Promise { - // 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, orgSlug, and sorting - const params = new URLSearchParams(); - if (username) { - params.append("username", username); - } - if (orgSlug) { - params.append("orgSlug", orgSlug); - } + // For authenticated users, no username/orgSlug params needed - API uses auth token + // This also ensures hidden event types are returned (they're filtered out when username is provided) // 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) - params.append("sortCreatedAt", "desc"); - - const queryString = params.toString(); - const endpoint = `/event-types${queryString ? `?${queryString}` : ""}`; + const endpoint = `/event-types?sortCreatedAt=desc`; const response = await makeRequest(endpoint, {}, "2024-06-14");