fix: #16028 Org Settings - SEOIndexing,Disable Org Url (#16075)

Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Hariom <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-11-29 10:21:14 +05:30
1 parent b5c6d7af91
commit f631abfdc4
20 files changed
+454 -23

No files matched your search

@@ -101,6 +101,13 @@ export async function getTeamWithMembers(args: {
isOrganization: true,
logoUrl: true,
metadata: true,
organizationSettings: {
select: {
allowSEOIndexing: true,
orgProfileRedirectsToVerifiedDomain: true,
orgAutoAcceptEmail: true,
},
},
},
},
parentId: true,
@@ -158,6 +165,13 @@ export async function getTeamWithMembers(args: {
identifier: true,
},
},
organizationSettings: {
select: {
allowSEOIndexing: true,
orgProfileRedirectsToVerifiedDomain: true,
orgAutoAcceptEmail: true,
},
},
},
} as const;
@@ -3,6 +3,7 @@ import { IS_TEAM_BILLING_ENABLED } from "@calcom/lib/constants";
import logger from "@calcom/lib/logger";
import { safeStringify } from "@calcom/lib/safeStringify";
import { prisma } from "@calcom/prisma";
import type { OrganizationSettings } from "@calcom/prisma/client";
import { MembershipRole } from "@calcom/prisma/enums";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
@@ -10,6 +11,11 @@ import { createAProfileForAnExistingUser } from "../../createAProfileForAnExisti
import { getParsedTeam } from "./teamUtils";
import { UserRepository } from "./user";
type MinimumOrganizationSettings = Pick<
OrganizationSettings,
"orgAutoAcceptEmail" | "orgProfileRedirectsToVerifiedDomain" | "allowSEOIndexing"
>;
type SEOOrganizationSettings = Pick<OrganizationSettings, "allowSEOIndexing">;
const orgSelect = {
id: true,
name: true,
@@ -215,6 +221,9 @@ export class OrganizationRepository {
lockEventTypeCreationForUsers: true,
adminGetsNoSlotsNotification: true,
isAdminReviewed: true,
allowSEOIndexing: true,
orgProfileRedirectsToVerifiedDomain: true,
orgAutoAcceptEmail: true,
},
});
@@ -229,6 +238,9 @@ export class OrganizationRepository {
organizationSettings: {
lockEventTypeCreationForUsers: organizationSettings?.lockEventTypeCreationForUsers,
adminGetsNoSlotsNotification: organizationSettings?.adminGetsNoSlotsNotification,
allowSEOIndexing: organizationSettings?.allowSEOIndexing,
orgProfileRedirectsToVerifiedDomain: organizationSettings?.orgProfileRedirectsToVerifiedDomain,
orgAutoAcceptEmail: organizationSettings?.orgAutoAcceptEmail,
},
user: {
role: membership?.role,
@@ -311,4 +323,38 @@ export class OrganizationRepository {
return org?.calVideoLogo;
}
static utils = {
/**
* Gets the organization setting if the team is an organization.
* If not, it gets the organization setting of the parent organization.
*/
getOrganizationSettings: (team: {
isOrganization: boolean;
organizationSettings: MinimumOrganizationSettings | null;
parent: {
organizationSettings: MinimumOrganizationSettings | null;
} | null;
}) => {
if (!team) return null;
if (team.isOrganization) return team.organizationSettings ?? null;
if (!team.parent) return null;
return team.parent.organizationSettings ?? null;
},
getOrganizationSEOSettings: (team: {
isOrganization: boolean;
organizationSettings: SEOOrganizationSettings | null;
parent: {
organizationSettings: SEOOrganizationSettings | null;
} | null;
}) => {
if (!team) return null;
if (team.isOrganization) return team.organizationSettings ?? null;
if (!team.parent) return null;
return team.parent.organizationSettings ?? null;
},
getVerifiedDomain(settings: Pick<OrganizationSettings, "orgAutoAcceptEmail">) {
return settings.orgAutoAcceptEmail;
},
};
}
+12 -1
View File
@@ -36,6 +36,10 @@ const membershipSelect = Prisma.validator<Prisma.MembershipSelect>()({
});
const log = logger.getSubLogger({ prefix: ["repository/profile"] });
const organizationSettingsSelect = Prisma.validator<Prisma.OrganizationSettingsSelect>()({
allowSEOIndexing: true,
orgProfileRedirectsToVerifiedDomain: true,
});
const organizationSelect = {
id: true,
slug: true,
@@ -45,6 +49,12 @@ const organizationSelect = {
bannerUrl: true,
isPlatform: true,
};
const organizationWithSettingsSelect = {
...organizationSelect,
organizationSettings: {
select: organizationSettingsSelect,
},
};
export enum LookupTarget {
User,
@@ -373,6 +383,7 @@ export class ProfileRepository {
organizationSettings: {
select: {
lockEventTypeCreationForUsers: true,
allowSEOIndexing: true,
},
},
members: {
@@ -416,7 +427,7 @@ export class ProfileRepository {
select: userSelect,
},
organization: {
select: organizationSelect,
select: organizationWithSettingsSelect,
},
},
});