Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: only return activated features (#5536)

DarkSkyb9fa002e67a6
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: {