fix(api): return empty bookingUrl for managed users in API v2 (#26826)

Managed users (isPlatformManaged: true) don't have public booking pages -
their scheduling is handled through the platform's app.

- Fetch isPlatformManaged in event-types repository
- Return empty string for managed users in buildBookingUrl
- Added unit test for managed users case

Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
This commit is contained in:
Dhairyashil Shinde
2026-01-14 15:28:25 +05:30
committed by GitHub
co-authored by Morgan
parent 4b99072bcc
commit c0017114ef
3 changed files with 30 additions and 0 deletions
@@ -65,6 +65,7 @@ export class EventTypesRepository_2024_06_14 {
id: true,
name: true,
username: true,
isPlatformManaged: true,
avatarUrl: true,
brandColor: true,
darkBrandColor: true,
@@ -111,6 +111,29 @@ describe("OutputEventTypesService_2024_06_14", () => {
expect(result).toBe("https://cal.com/dhairyashil/secret");
});
it("should return empty string for managed users", () => {
const user = {
id: 1,
name: "Managed User",
username: "managed-user-abc123",
isPlatformManaged: true,
avatarUrl: null,
brandColor: null,
darkBrandColor: null,
weekStart: "Monday",
metadata: {},
organizationId: 1,
organization: { slug: "platform-org" },
movedToProfile: null,
profiles: [],
};
const slug = "30min";
const result = service.buildBookingUrl(user, slug);
expect(result).toBe("");
});
it("should fall back to user username when profile has no username", () => {
const user = {
id: 1,
@@ -47,6 +47,7 @@ type EventTypeUser = {
id: number;
name: string | null;
username: string | null;
isPlatformManaged?: boolean;
avatarUrl: string | null;
brandColor: string | null;
darkBrandColor: string | null;
@@ -441,6 +442,11 @@ export class OutputEventTypesService_2024_06_14 {
return "";
}
// Managed users don't have public booking pages
if (user.isPlatformManaged) {
return "";
}
const profile = this.usersService.getUserMainProfile(user);
const username = profile?.username ?? user.username;