From b9fa002e67a6e21f0465d5ec94fbd5731135b0a2 Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:58:59 +0800 Subject: [PATCH] fix: only return activated features (#5536) --- .../backend/server/src/modules/features/management.ts | 2 +- .../backend/server/src/modules/features/service.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/backend/server/src/modules/features/management.ts b/packages/backend/server/src/modules/features/management.ts index 0b36df4fad..57766fc519 100644 --- a/packages/backend/server/src/modules/features/management.ts +++ b/packages/backend/server/src/modules/features/management.ts @@ -92,7 +92,7 @@ export class FeatureManagementService { async getWorkspaceFeatures(workspaceId: string) { const features = await this.feature.getWorkspaceFeatures(workspaceId); - return features.map(feature => feature.feature.name); + return features.filter(f => f.activated).map(f => f.feature.name); } async hasWorkspaceFeature(workspaceId: string, feature: FeatureType) { diff --git a/packages/backend/server/src/modules/features/service.ts b/packages/backend/server/src/modules/features/service.ts index afed8a1b84..b7bf53c023 100644 --- a/packages/backend/server/src/modules/features/service.ts +++ b/packages/backend/server/src/modules/features/service.ts @@ -126,6 +126,11 @@ export class FeatureService { .then(r => r.count); } + /** + * get user's features, will included inactivated features + * @param userId user id + * @returns list of features + */ async getUserFeatures(userId: string) { const features = await this.prisma.userFeatures.findMany({ where: { @@ -265,6 +270,11 @@ export class FeatureService { .then(r => r.count); } + /** + * get workspace's features, will included inactivated features + * @param workspaceId workspace id + * @returns list of features + */ async getWorkspaceFeatures(workspaceId: string) { const features = await this.prisma.workspaceFeatures.findMany({ where: {