fix: cascade organization hideBranding setting to user and team events (#21703)

- Add utility function for cascading hideBranding logic
- Update all getServerSideProps files to check organization hideBranding as fallback
- Ensure team queries include parent hideBranding data
- Fix hideBranding not working for organization members and teams

Fixes the issue where organization-level branding settings were not
being applied to user and team event pages when the direct entity
didn't have hideBranding enabled.

Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
devin-ai-integration[bot]andHariom Balhara authored and GitHub committed 2025-06-12 09:14:55 -03:00
1 parent 2aaf672b10
commit 2fcb8a750d
10 files changed
+220 -7

No files matched your search

+5
View File
@@ -70,6 +70,11 @@ export const getEventTypesFromDB = async (id: number) => {
slug: true,
name: true,
hideBranding: true,
parent: {
select: {
hideBranding: true,
},
},
},
},
workflows: {
@@ -6,6 +6,7 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { getBookingForReschedule, getMultipleDurationValue } from "@calcom/features/bookings/lib/get-booking";
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import { shouldHideBrandingForTeamEvent, shouldHideBrandingForUserEvent } from "@calcom/lib/hideBranding";
import { EventRepository } from "@calcom/lib/server/repository/event";
import { UserRepository } from "@calcom/lib/server/repository/user";
import slugify from "@calcom/lib/slugify";
@@ -49,6 +50,11 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
id: true,
slug: true,
hideBranding: true,
parent: {
select: {
hideBranding: true,
},
},
},
},
},
@@ -71,7 +77,10 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
if (hashedLink.eventType.team) {
name = hashedLink.eventType.team.slug || "";
hideBranding = hashedLink.eventType.team.hideBranding;
hideBranding = shouldHideBrandingForTeamEvent({
eventTypeId: hashedLink.eventTypeId,
team: hashedLink.eventType.team,
});
} else {
if (!username) {
return notFound;
@@ -101,7 +110,10 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
return notFound;
}
hideBranding = user.hideBranding;
hideBranding = shouldHideBrandingForUserEvent({
eventTypeId: hashedLink.eventTypeId,
owner: user,
});
}
let booking: GetBookingType | null = null;
@@ -5,6 +5,7 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { getMultipleDurationValue } from "@calcom/features/bookings/lib/get-booking";
import { getSlugOrRequestedSlug } from "@calcom/features/ee/organizations/lib/orgDomains";
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import { shouldHideBrandingForTeamEvent } from "@calcom/lib/hideBranding";
import { EventRepository } from "@calcom/lib/server/repository/event";
import slugify from "@calcom/lib/slugify";
import prisma from "@calcom/prisma";
@@ -28,6 +29,11 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
select: {
id: true,
hideBranding: true,
parent: {
select: {
hideBranding: true,
},
},
},
});
@@ -75,7 +81,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
user: teamSlug,
teamId: team.id,
slug: meetingSlug,
isBrandingHidden: team?.hideBranding,
isBrandingHidden: shouldHideBrandingForTeamEvent({
eventTypeId: eventData.id,
team,
}),
themeBasis: null,
},
};
@@ -8,6 +8,7 @@ import { getSlugOrRequestedSlug, orgDomainConfig } from "@calcom/features/ee/org
import { getOrganizationSEOSettings } from "@calcom/features/ee/organizations/lib/orgSettings";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
import { shouldHideBrandingForTeamEvent } from "@calcom/lib/hideBranding";
import slugify from "@calcom/lib/slugify";
import prisma from "@calcom/prisma";
import type { User } from "@calcom/prisma/client";
@@ -156,7 +157,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
user: teamSlug,
teamId: team.id,
slug: meetingSlug,
isBrandingHidden: team?.hideBranding,
isBrandingHidden: shouldHideBrandingForTeamEvent({
eventTypeId: eventData.id,
team,
}),
isInstantMeeting: eventData && queryIsInstantMeeting ? true : false,
themeBasis: null,
orgBannerUrl: team.parent?.bannerUrl ?? "",
@@ -192,6 +196,7 @@ const getTeamWithEventsData = async (
name: true,
bannerUrl: true,
logoUrl: true,
hideBranding: true,
organizationSettings: {
select: {
allowSEOIndexing: true,
@@ -6,6 +6,7 @@ import { orgDomainConfig } from "@calcom/ee/organizations/lib/orgDomains";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import getBookingInfo from "@calcom/features/bookings/lib/getBookingInfo";
import { getDefaultEvent } from "@calcom/lib/defaultEvents";
import { shouldHideBrandingForEvent } from "@calcom/lib/hideBranding";
import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
import { maybeGetBookingUidFromSeat } from "@calcom/lib/server/maybeGetBookingUidFromSeat";
@@ -229,7 +230,12 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
props: {
orgSlug: currentOrgDomain,
themeBasis: eventType.team ? eventType.team.slug : eventType.users[0]?.username,
hideBranding: eventType.team ? eventType.team.hideBranding : eventType.users[0].hideBranding,
hideBranding: await shouldHideBrandingForEvent({
eventTypeId: eventType.id,
team: eventType.team,
owner: eventType.users[0] ?? null,
orgSlug: currentOrgDomain,
}),
profile,
eventType,
recurringBookings: await getRecurringBookings(bookingInfo.recurringEventId),
@@ -8,6 +8,7 @@ import { getBookingForReschedule, getBookingForSeatedEvent } from "@calcom/featu
import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import type { getPublicEvent } from "@calcom/features/eventtypes/lib/getPublicEvent";
import { getUsernameList } from "@calcom/lib/defaultEvents";
import { shouldHideBrandingForUserEvent } from "@calcom/lib/hideBranding";
import { EventRepository } from "@calcom/lib/server/repository/event";
import { UserRepository } from "@calcom/lib/server/repository/user";
import slugify from "@calcom/lib/slugify";
@@ -270,7 +271,10 @@ async function getUserPageProps(context: GetServerSidePropsContext) {
eventData: eventData,
user: username,
slug,
isBrandingHidden: user?.hideBranding,
isBrandingHidden: shouldHideBrandingForUserEvent({
eventTypeId: eventData.id,
owner: user,
}),
isSEOIndexable: allowSEOIndexing,
themeBasis: username,
bookingUid: bookingUid ? `${bookingUid}` : null,