Allow free access for configuration using billing

This commit is contained in:
Charles Bochet
2024-08-04 01:37:53 +02:00
parent 76185c2f68
commit e2b42ee6c9
3 changed files with 16 additions and 5 deletions

View File

@ -1,12 +1,13 @@
import { Module } from '@nestjs/common';
import { BillingModule } from 'src/engine/core-modules/billing/billing.module';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
import { OnboardingResolver } from 'src/engine/core-modules/onboarding/onboarding.resolver';
import { OnboardingService } from 'src/engine/core-modules/onboarding/onboarding.service';
import { UserVarsModule } from 'src/engine/core-modules/user/user-vars/user-vars.module';
@Module({
imports: [BillingModule, UserVarsModule],
imports: [BillingModule, UserVarsModule, FeatureFlagModule],
exports: [OnboardingService],
providers: [OnboardingService, OnboardingResolver],
})

View File

@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common';
import { SubscriptionStatus } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { IsFeatureEnabledService } from 'src/engine/core-modules/feature-flag/services/is-feature-enabled.service';
import { OnboardingStatus } from 'src/engine/core-modules/onboarding/enums/onboarding-status.enum';
import { UserVarsService } from 'src/engine/core-modules/user/user-vars/services/user-vars.service';
import { User } from 'src/engine/core-modules/user/user.entity';
@ -26,6 +28,7 @@ export class OnboardingService {
constructor(
private readonly billingSubscriptionService: BillingSubscriptionService,
private readonly environmentService: EnvironmentService,
private readonly isFeatureEnabledService: IsFeatureEnabledService,
private readonly userVarsService: UserVarsService<OnboardingKeyValueTypeMap>,
) {}
@ -36,6 +39,16 @@ export class OnboardingService {
return false;
}
const isFreeAccessEnabled =
await this.isFeatureEnabledService.isFeatureEnabled(
FeatureFlagKey.IsFreeAccessEnabled,
user.defaultWorkspaceId,
);
if (isFreeAccessEnabled) {
return false;
}
const currentBillingSubscription =
await this.billingSubscriptionService.getCurrentBillingSubscription({
workspaceId: user.defaultWorkspaceId,