Skip to content

Scheduling infrastructure for absolutely everyone.

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

Dhairyashil Shindec0017114efae
diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts
index f81c81d7dc5..54c9bb006b1 100644
--- a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts
+++ b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts
@@ -65,6 +65,7 @@ export class EventTypesRepository_2024_06_14 {
id: true,
name: true,
username: true,
+ isPlatformManaged: true,
avatarUrl: true,
brandColor: true,
darkBrandColor: true,
diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.spec.ts b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.spec.ts
index cb4c11c0a9c..c71d1d9e6e4 100644
--- a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.spec.ts
+++ b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.spec.ts
@@ -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,
diff --git a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts
index 0e27ac332ac..75869a39678 100644
--- a/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts
+++ b/apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts
@@ -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;