From dbab03d370f4ba9208fd59ad36799d973134574b Mon Sep 17 00:00:00 2001 From: Valentin Yanakiev Date: Fri, 20 Dec 2024 18:05:11 +0200 Subject: [PATCH] make settingsStr --> settings and JSON instead of text in mySQL --- .../space.settings/space.settings.service.ts | 13 --- .../space/sort.spaces.by.activity.spec.ts | 22 +++- src/domain/space/space/space.entity.ts | 6 +- src/domain/space/space/space.interface.ts | 3 +- .../space/space/space.resolver.fields.ts | 2 +- .../space/space.service.authorization.ts | 4 +- src/domain/space/space/space.service.spec.ts | 107 ++++++++++++++++-- src/domain/space/space/space.service.ts | 103 +++++++++-------- .../calendar/calendar.resolver.fields.ts | 5 +- .../1734708463412-spaceSettingsJSON.ts | 24 ++++ src/services/api/roles/roles.service.spec.ts | 22 +++- .../search/v2/result/search.result.service.ts | 14 ++- .../infrastructure/naming/naming.service.ts | 4 +- 13 files changed, 241 insertions(+), 88 deletions(-) create mode 100644 src/migrations/1734708463412-spaceSettingsJSON.ts diff --git a/src/domain/space/space.settings/space.settings.service.ts b/src/domain/space/space.settings/space.settings.service.ts index edcae89c8c..bb458366f6 100644 --- a/src/domain/space/space.settings/space.settings.service.ts +++ b/src/domain/space/space.settings/space.settings.service.ts @@ -9,19 +9,6 @@ export class SpaceSettingsService { @Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService ) {} - public getSettings(settingsStr: string): ISpaceSettings { - const states: ISpaceSettings = this.deserializeSettings(settingsStr); - return states; - } - - public serializeSettings(settings: ISpaceSettings): string { - return JSON.stringify(settings); - } - - private deserializeSettings(settingsStr: string): ISpaceSettings { - return JSON.parse(settingsStr); - } - public updateSettings( settings: ISpaceSettings, updateData: UpdateSpaceSettingsEntityInput diff --git a/src/domain/space/space/sort.spaces.by.activity.spec.ts b/src/domain/space/space/sort.spaces.by.activity.spec.ts index d16a8d2cb7..4cde28ffbc 100644 --- a/src/domain/space/space/sort.spaces.by.activity.spec.ts +++ b/src/domain/space/space/sort.spaces.by.activity.spec.ts @@ -7,6 +7,8 @@ import { SpaceType } from '@common/enums/space.type'; import { SpaceVisibility } from '@common/enums/space.visibility'; import { ProfileType } from '@common/enums'; import { AccountType } from '@common/enums/account.type'; +import { CommunityMembershipPolicy } from '@common/enums/community.membership.policy'; +import { SpacePrivacyMode } from '@common/enums/space.privacy.mode'; const createTestActivity = (createdDate: Date): IActivity => { return { @@ -22,12 +24,30 @@ const createTestActivity = (createdDate: Date): IActivity => { }; }; +const spaceSettings = { + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + membership: { + policy: CommunityMembershipPolicy.OPEN, + trustedOrganizations: [], + allowSubspaceAdminsToInviteMembers: false, + }, + collaboration: { + inheritMembershipRights: true, + allowMembersToCreateSubspaces: true, + allowMembersToCreateCallouts: true, + allowEventsFromSubspaces: true, + }, +}; + const createTestSpace = (id: string): ISpace => { return { id, rowId: 1, nameID: 'space1', - settingsStr: '', + settings: spaceSettings, levelZeroSpaceID: '', visibility: SpaceVisibility.ACTIVE, profile: { diff --git a/src/domain/space/space/space.entity.ts b/src/domain/space/space/space.entity.ts index 50c132b221..4ab7223ee3 100644 --- a/src/domain/space/space/space.entity.ts +++ b/src/domain/space/space/space.entity.ts @@ -22,6 +22,7 @@ import { Profile } from '@domain/common/profile'; import { TemplatesManager } from '@domain/template/templates-manager'; import { License } from '@domain/common/license/license.entity'; import { SpaceLevel } from '@common/enums/space.level'; +import { ISpaceSettings } from '../space.settings/space.settings.interface'; @Entity() export class Space extends NameableEntity implements ISpace { @OneToOne(() => Profile, { @@ -85,8 +86,8 @@ export class Space extends NameableEntity implements ISpace { @JoinColumn() agent?: Agent; - @Column('text') - settingsStr: string = ''; + @Column('json', { nullable: true }) + settings: ISpaceSettings; @OneToOne(() => StorageAggregator, { eager: false, @@ -130,5 +131,6 @@ export class Space extends NameableEntity implements ISpace { constructor() { super(); this.nameID = ''; + this.settings = {} as ISpaceSettings; } } diff --git a/src/domain/space/space/space.interface.ts b/src/domain/space/space/space.interface.ts index 10208e16c9..60648cdb1a 100644 --- a/src/domain/space/space/space.interface.ts +++ b/src/domain/space/space/space.interface.ts @@ -11,6 +11,7 @@ import { SpaceVisibility } from '@common/enums/space.visibility'; import { ITemplatesManager } from '@domain/template/templates-manager'; import { ILicense } from '@domain/common/license/license.interface'; import { SpaceLevel } from '@common/enums/space.level'; +import { ISpaceSettings } from '../space.settings/space.settings.interface'; @ObjectType('Space') export class ISpace extends INameable { @@ -46,7 +47,7 @@ export class ISpace extends INameable { context?: IContext; community?: ICommunity; - settingsStr!: string; + settings!: ISpaceSettings; storageAggregator?: IStorageAggregator; diff --git a/src/domain/space/space/space.resolver.fields.ts b/src/domain/space/space/space.resolver.fields.ts index 230cd490e3..efecffb8cd 100644 --- a/src/domain/space/space/space.resolver.fields.ts +++ b/src/domain/space/space/space.resolver.fields.ts @@ -251,7 +251,7 @@ export class SpaceResolverFields { }) @UseGuards(GraphqlGuard) settings(@Parent() space: ISpace): ISpaceSettings { - return this.spaceService.getSettings(space); + return space.settings; } @AuthorizationAgentPrivilege(AuthorizationPrivilege.READ) diff --git a/src/domain/space/space/space.service.authorization.ts b/src/domain/space/space/space.service.authorization.ts index 2c52b038a1..d42762c9da 100644 --- a/src/domain/space/space/space.service.authorization.ts +++ b/src/domain/space/space/space.service.authorization.ts @@ -104,9 +104,7 @@ export class SpaceAuthorizationService { const updatedAuthorizations: IAuthorizationPolicy[] = []; const spaceVisibility = space.visibility; - const spaceSettings = this.spaceSettingsService.getSettings( - space.settingsStr - ); + const spaceSettings = space.settings; const isPrivate = spaceSettings.privacy.mode === SpacePrivacyMode.PRIVATE; // Store the provided parent authorization so that later resets can happen diff --git a/src/domain/space/space/space.service.spec.ts b/src/domain/space/space/space.service.spec.ts index 56cf45eb05..c1950aa299 100644 --- a/src/domain/space/space/space.service.spec.ts +++ b/src/domain/space/space/space.service.spec.ts @@ -21,6 +21,8 @@ import { AccountType } from '@common/enums/account.type'; import { Repository } from 'typeorm'; import { getRepositoryToken } from '@nestjs/typeorm'; import { ISpaceSettings } from '@domain/space/space.settings/space.settings.interface'; +import { SpacePrivacyMode } from '@common/enums/space.privacy.mode'; +import { CommunityMembershipPolicy } from '@common/enums/community.membership.policy'; const moduleMocker = new ModuleMocker(global); @@ -56,11 +58,10 @@ describe('SpaceService', () => { } as ISpaceSettings; const space = { id: spaceId, - settingsStr: JSON.stringify(settingsData), + settings: settingsData, } as Space; jest.spyOn(spaceRepository, 'findOneOrFail').mockResolvedValue(space); - jest.spyOn(service, 'getSettings').mockReturnValue(settingsData); const result = await service.shouldUpdateAuthorizationPolicy( spaceId, @@ -85,11 +86,10 @@ describe('SpaceService', () => { } as ISpaceSettings; const space = { id: spaceId, - settingsStr: JSON.stringify(originalSettings), + settings: originalSettings, } as Space; jest.spyOn(spaceRepository, 'findOneOrFail').mockResolvedValue(space); - jest.spyOn(service, 'getSettings').mockReturnValue(originalSettings); const result = await service.shouldUpdateAuthorizationPolicy( spaceId, @@ -108,11 +108,10 @@ describe('SpaceService', () => { } as ISpaceSettings; const space = { id: spaceId, - settingsStr: JSON.stringify(originalSettings), + settings: originalSettings, } as Space; jest.spyOn(spaceRepository, 'findOneOrFail').mockResolvedValue(space); - jest.spyOn(service, 'getSettings').mockReturnValue(originalSettings); const result = await service.shouldUpdateAuthorizationPolicy( spaceId, @@ -252,6 +251,24 @@ const getAuthorizationPolicyMock = ( ...getEntityMock(), }); +const spaceSettings = { + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + membership: { + policy: CommunityMembershipPolicy.OPEN, + trustedOrganizations: [], + allowSubspaceAdminsToInviteMembers: false, + }, + collaboration: { + inheritMembershipRights: true, + allowMembersToCreateSubspaces: true, + allowMembersToCreateCallouts: true, + allowEventsFromSubspaces: true, + }, +}; + const getSubspacesMock = ( spaceId: string, count: number, @@ -263,7 +280,7 @@ const getSubspacesMock = ( id: `${spaceId}.${i}`, rowId: i, nameID: `challenge-${spaceId}.${i}`, - settingsStr: JSON.stringify({}), + settings: spaceSettings, levelZeroSpaceID: spaceId, account: { id: `account-${spaceId}.${i}`, @@ -360,7 +377,7 @@ const getSubsubspacesMock = (subsubspaceId: string, count: number): Space[] => { id: `${subsubspaceId}.${i}`, rowId: i, nameID: `subsubspace-${subsubspaceId}.${i}`, - settingsStr: JSON.stringify({}), + settings: spaceSettings, levelZeroSpaceID: subsubspaceId, account: { id: `account-${subsubspaceId}.${i}`, @@ -452,18 +469,20 @@ const getSpaceMock = ({ anonymousReadAccess, challengesCount, opportunitiesCounts, + settings, }: { id: string; visibility: SpaceVisibility; anonymousReadAccess: boolean; challengesCount: number; opportunitiesCounts: number[]; + settings: ISpaceSettings; }): Space => { return { id, rowId: parseInt(id), nameID: `space-${id}`, - settingsStr: JSON.stringify({}), + settings: settings, levelZeroSpaceID: '', profile: { id: `profile-${id}`, @@ -512,6 +531,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ACTIVE, challengesCount: 1, opportunitiesCounts: [5], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '2', @@ -519,6 +545,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ACTIVE, challengesCount: 2, opportunitiesCounts: [5, 3], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '3', @@ -526,6 +559,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.DEMO, challengesCount: 3, opportunitiesCounts: [5, 3, 1], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '4', @@ -533,6 +573,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.DEMO, challengesCount: 3, opportunitiesCounts: [1, 2, 1], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PRIVATE, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '5', @@ -540,6 +587,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ACTIVE, challengesCount: 1, opportunitiesCounts: [1], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PRIVATE, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '6', @@ -547,6 +601,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ACTIVE, challengesCount: 3, opportunitiesCounts: [1, 1, 6], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '7', @@ -554,6 +615,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ARCHIVED, challengesCount: 0, opportunitiesCounts: [], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '8', @@ -561,6 +629,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.DEMO, challengesCount: 0, opportunitiesCounts: [], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '9', @@ -568,6 +643,13 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.ACTIVE, challengesCount: 0, opportunitiesCounts: [], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PRIVATE, + allowPlatformSupportAsAdmin: false, + }, + }, }), getSpaceMock({ id: '10', @@ -575,5 +657,12 @@ const spaceTestData: Space[] = [ visibility: SpaceVisibility.DEMO, challengesCount: 3, opportunitiesCounts: [1, 2, 0], + settings: { + ...spaceSettings, + privacy: { + mode: SpacePrivacyMode.PRIVATE, + allowPlatformSupportAsAdmin: false, + }, + }, }), ]; diff --git a/src/domain/space/space/space.service.ts b/src/domain/space/space/space.service.ts index 574e2232b3..c6b97121a9 100644 --- a/src/domain/space/space/space.service.ts +++ b/src/domain/space/space/space.service.ts @@ -34,7 +34,6 @@ import { IPaginatedType } from '@core/pagination/paginated.type'; import { SpaceFilterInput } from '@services/infrastructure/space-filter/dto/space.filter.dto.input'; import { PaginationArgs } from '@core/pagination'; import { getPaginationResults } from '@core/pagination/pagination.fn'; -import { ISpaceSettings } from '../space.settings/space.settings.interface'; import { SpaceType } from '@common/enums/space.type'; import { UpdateSpacePlatformSettingsInput } from './dto/space.dto.update.platform.settings'; import { TagsetReservedName } from '@common/enums/tagset.reserved.name'; @@ -84,10 +83,18 @@ import { LicenseService } from '@domain/common/license/license.service'; import { LicenseType } from '@common/enums/license.type'; import { getDiff, hasOnlyAllowedFields } from '@common/utils'; import { ILicensePlan } from '@platform/licensing/credential-based/license-plan/license.plan.interface'; +import { SpacePrivacyMode } from '@common/enums/space.privacy.mode'; const EXPLORE_SPACES_LIMIT = 30; const EXPLORE_SPACES_ACTIVITY_DAYS_OLD = 30; +type SpaceSortingData = { + id: string; + subspacesCount: number; + visibility: SpaceVisibility; + accessModeIsPublic: boolean; +}; + @Injectable() export class SpaceService { constructor( @@ -152,8 +159,8 @@ export class SpaceService { space.authorization = new AuthorizationPolicy( AuthorizationPolicyType.SPACE ); - space.settingsStr = this.spaceSettingsService.serializeSettings( - this.spaceDefaultsService.getDefaultSpaceSettings(spaceData.type) + space.settings = this.spaceDefaultsService.getDefaultSpaceSettings( + spaceData.type ); const storageAggregator = @@ -588,51 +595,37 @@ export class SpaceService { } private sortSpacesDefault(spacesData: Space[]): string[] { - const sortedSpaces = spacesData.sort((a, b) => { - const visibilityA = a.visibility; - const visibilityB = b.visibility; - if ( - visibilityA !== visibilityB && - (visibilityA === SpaceVisibility.DEMO || - visibilityB === SpaceVisibility.DEMO) - ) - return visibilityA === SpaceVisibility.DEMO ? 1 : -1; - - if ( - a.authorization?.anonymousReadAccess === true && - b.authorization?.anonymousReadAccess === false - ) - return -1; + const spacesDataForSorting: SpaceSortingData[] = []; + for (const space of spacesData) { + const settings = space.settings; + let subspacesCount = 0; + if (space.subspaces) { + subspacesCount = this.getSubspaceAndSubsubspacesCount(space.subspaces); + } + const spaceSortingData: SpaceSortingData = { + id: space.id, + visibility: space.visibility, + accessModeIsPublic: settings.privacy.mode === SpacePrivacyMode.PUBLIC, + subspacesCount, + }; + spacesDataForSorting.push(spaceSortingData); + } + const sortedSpaces = spacesDataForSorting.sort((a, b) => { if ( - a.authorization?.anonymousReadAccess === false && - b.authorization?.anonymousReadAccess === true + a.visibility !== b.visibility && + (a.visibility === SpaceVisibility.DEMO || + b.visibility === SpaceVisibility.DEMO) ) - return 1; - - if (!a.subspaces && b.subspaces) return 1; - if (a.subspaces && !b.subspaces) return -1; - if (!a.subspaces && !b.subspaces) return 0; - - // Shouldn't get there - if (!a.subspaces || !b.subspaces) - throw new ValidationException( - `Critical error when comparing Spaces! Critical error when loading Subspaces for Space ${a} and Space ${b}`, - LogContext.SPACES - ); + return a.visibility === SpaceVisibility.DEMO ? 1 : -1; - const subspacesCountA = this.getSubspaceAndSubsubspacesCount( - a?.subspaces - ); - const subspacesCountB = this.getSubspaceAndSubsubspacesCount( - b?.subspaces - ); + if (a.accessModeIsPublic && !b.accessModeIsPublic) return -1; + if (!a.accessModeIsPublic && b.accessModeIsPublic) return 1; - if (subspacesCountA > subspacesCountB) return -1; - if (subspacesCountA < subspacesCountB) return 1; + if (a.subspacesCount > b.subspacesCount) return -1; + if (a.subspacesCount < b.subspacesCount) return 1; return 0; }); - const sortedIDs: string[] = []; for (const space of sortedSpaces) { sortedIDs.push(space.id); @@ -831,10 +824,25 @@ export class SpaceService { ): Promise { const space = await this.spaceRepository.findOneOrFail({ where: { id: spaceId }, - select: { id: true, settingsStr: true }, + select: { + id: true, + settings: { + collaboration: { + allowEventsFromSubspaces: true, + allowMembersToCreateCallouts: true, + allowMembersToCreateSubspaces: true, + inheritMembershipRights: true, + }, + membership: { + allowSubspaceAdminsToInviteMembers: true, + policy: true, + }, + privacy: { allowPlatformSupportAsAdmin: true, mode: true }, + }, + }, }); - const originalSettings = this.getSettings(space as ISpace); + const originalSettings = space.settings; // compare the new values from the incoming update request with the original settings const difference = getDiff(settingsData, originalSettings); // if there is no difference, then no need to update the authorization policy @@ -1172,10 +1180,6 @@ export class SpaceService { return subspace; } - public getSettings(space: ISpace): ISpaceSettings { - return this.spaceSettingsService.getSettings(space.settingsStr); - } - private async setRoleSetHierarchyForSubspace( parentCommunity: ICommunity, childCommunity: ICommunity | undefined @@ -1204,13 +1208,12 @@ export class SpaceService { space: ISpace, settingsData: UpdateSpaceSettingsEntityInput ): Promise { - const settings = this.spaceSettingsService.getSettings(space.settingsStr); + const settings = space.settings; const updatedSettings = this.spaceSettingsService.updateSettings( settings, settingsData ); - space.settingsStr = - this.spaceSettingsService.serializeSettings(updatedSettings); + space.settings = updatedSettings; return await this.save(space); } diff --git a/src/domain/timeline/calendar/calendar.resolver.fields.ts b/src/domain/timeline/calendar/calendar.resolver.fields.ts index bfb35a397d..9053c75d94 100644 --- a/src/domain/timeline/calendar/calendar.resolver.fields.ts +++ b/src/domain/timeline/calendar/calendar.resolver.fields.ts @@ -54,10 +54,7 @@ export class CalendarResolverFields { calendar.id ); - const spaceSettings = this.spaceSettingsService.getSettings( - space.settingsStr - ); - + const spaceSettings = space.settings; const shouldSubspaceEventsBubble = spaceSettings.collaboration.allowEventsFromSubspaces; diff --git a/src/migrations/1734708463412-spaceSettingsJSON.ts b/src/migrations/1734708463412-spaceSettingsJSON.ts new file mode 100644 index 0000000000..f134e97e06 --- /dev/null +++ b/src/migrations/1734708463412-spaceSettingsJSON.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class SpaceSettingsJSON1734708463412 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`space\` CHANGE \`settingsStr\` \`settings\` text NOT NULL` + ); + await queryRunner.query( + "UPDATE `space` SET `settings` = '[]' WHERE `settings` IS NULL OR `settings` = ''" + ); + await queryRunner.query( + 'ALTER TABLE `space` MODIFY COLUMN `settings` json null' + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + 'ALTER TABLE `space` MODIFY COLUMN `settings` text' + ); + await queryRunner.query( + `ALTER TABLE \`space\` CHANGE \`settings\` \`settingsStr\` text NOT NULL` + ); + } +} diff --git a/src/services/api/roles/roles.service.spec.ts b/src/services/api/roles/roles.service.spec.ts index 8fc48c3628..87f74ccc7d 100644 --- a/src/services/api/roles/roles.service.spec.ts +++ b/src/services/api/roles/roles.service.spec.ts @@ -33,6 +33,8 @@ import { MockVirtualContributorService } from '@test/mocks/virtual.contributor.s import { IUser } from '@domain/community/user/user.interface'; import { CommunityResolverService } from '@services/infrastructure/entity-resolver/community.resolver.service'; import { AccountType } from '@common/enums/account.type'; +import { CommunityMembershipPolicy } from '@common/enums/community.membership.policy'; +import { SpacePrivacyMode } from '@common/enums/space.privacy.mode'; describe('RolesService', () => { let rolesService: RolesService; @@ -206,6 +208,24 @@ describe('RolesService', () => { }); }); +const spaceSettings = { + privacy: { + mode: SpacePrivacyMode.PUBLIC, + allowPlatformSupportAsAdmin: false, + }, + membership: { + policy: CommunityMembershipPolicy.OPEN, + trustedOrganizations: [], + allowSubspaceAdminsToInviteMembers: false, + }, + collaboration: { + inheritMembershipRights: true, + allowMembersToCreateSubspaces: true, + allowMembersToCreateCallouts: true, + allowEventsFromSubspaces: true, + }, +}; + const getSpaceRoleResultMock = ({ id, roles, @@ -226,7 +246,7 @@ const getSpaceRoleResultMock = ({ roles, space: { id, - settingsStr: JSON.stringify({}), + settings: spaceSettings, rowId: parseInt(id), nameID: `space-${id}`, levelZeroSpaceID: '', diff --git a/src/services/api/search/v2/result/search.result.service.ts b/src/services/api/search/v2/result/search.result.service.ts index f7471fdc37..50987ad742 100644 --- a/src/services/api/search/v2/result/search.result.service.ts +++ b/src/services/api/search/v2/result/search.result.service.ts @@ -625,7 +625,19 @@ export class SearchResultService { id: true, type: true, level: true, - settingsStr: true, + settings: { + collaboration: { + allowEventsFromSubspaces: true, + allowMembersToCreateCallouts: true, + allowMembersToCreateSubspaces: true, + inheritMembershipRights: true, + }, + membership: { + allowSubspaceAdminsToInviteMembers: true, + policy: true, + }, + privacy: { allowPlatformSupportAsAdmin: true, mode: true }, + }, visibility: true, collaboration: { id: true, diff --git a/src/services/infrastructure/naming/naming.service.ts b/src/services/infrastructure/naming/naming.service.ts index c2e48f7cf6..b52f55ba78 100644 --- a/src/services/infrastructure/naming/naming.service.ts +++ b/src/services/infrastructure/naming/naming.service.ts @@ -264,7 +264,7 @@ export class NamingService { } // Directly parse the settings string to avoid the need to load the settings service const roleSet = space.community.roleSet; - const spaceSettings: ISpaceSettings = JSON.parse(space.settingsStr); + const spaceSettings: ISpaceSettings = space.settings; return { roleSet, spaceSettings }; } @@ -295,7 +295,7 @@ export class NamingService { // Directly parse the settings string to avoid the need to load the settings service const roleSet = space.community.roleSet; - const spaceSettings: ISpaceSettings = JSON.parse(space.settingsStr); + const spaceSettings: ISpaceSettings = space.settings; return { roleSet: roleSet, spaceSettings }; }