fix: only return activated features (#5536)

This commit is contained in:
DarkSky 2024-01-08 15:58:59 +08:00 committed by GitHub
parent d7b9462d1c
commit b9fa002e67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -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) {

View File

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