fix(api): skip platform org subdomain in bookingUrl for API v2 (#26812)

Platform organizations don't have public-facing subdomains, so non-managed
users in platform orgs should get cal.com URLs instead of the platform
org subdomain.

- Updated EventTypeUser type to include isPlatform field
- Modified buildBookingUrl to check isPlatform before using org slug
- Added unit test for platform org users

Co-authored-by: Morgan <[email protected]>
This commit is contained in:
Dhairyashil ShindeandMorgan authored and GitHub committed 2026-01-14 09:04:45 +00:00
1 parent 3860717ae3
commit 821dce6a04
3 files changed
+63 -20

No files matched your search

@@ -82,6 +82,35 @@ describe("OutputEventTypesService_2024_06_14", () => {
expect(result).toBe("https://acme.cal.com/owner1/30min");
});
it("should use cal.com for non-managed users in platform orgs", () => {
const user = {
id: 1,
name: "Dhairyashil Shinde",
username: "dhairyashil10101010-gmail-com",
avatarUrl: null,
brandColor: null,
darkBrandColor: null,
weekStart: "Monday",
metadata: {},
organizationId: 1,
organization: { slug: "gmail-platform-9041df0e" },
movedToProfile: null,
profiles: [
{
id: 100,
username: "dhairyashil",
organizationId: 1,
organization: { id: 1, slug: "gmail-platform-9041df0e", isPlatform: true },
},
],
};
const slug = "secret";
const result = service.buildBookingUrl(user, slug);
expect(result).toBe("https://cal.com/dhairyashil/secret");
});
it("should fall back to user username when profile has no username", () => {
const user = {
id: 1,
@@ -53,7 +53,7 @@ type EventTypeUser = {
weekStart: string;
metadata: Prisma.JsonValue;
organizationId: number | null;
organization?: { slug: string | null } | null;
organization?: { slug: string | null; isPlatform?: boolean } | null;
movedToProfile?: ProfileMinimal | null;
profiles?: ProfileMinimal[];
};
@@ -448,7 +448,9 @@ export class OutputEventTypesService_2024_06_14 {
return "";
}
const orgSlug = profile?.organization?.slug ?? null;
const org = profile?.organization;
// Don't use org subdomain for platform organizations - they don't have public-facing subdomains
const orgSlug = org && !org.isPlatform ? org.slug : null;
const webAppUrl = this.configService.get<string>("app.baseUrl", "https://app.cal.com");
const baseUrl = orgSlug ? getBookerBaseUrlSync(orgSlug) : webAppUrl;
const normalizedBaseUrl = baseUrl.replace(/\/$/, "");