Remove Feature Flag on Calendar (#5288)

Remove Calendar feature Flag!
This commit is contained in:
Charles Bochet
2024-05-03 19:10:33 +02:00
committed by GitHub
parent 381bf0fc8d
commit a750901582
22 changed files with 36 additions and 187 deletions

View File

@ -1,9 +1,4 @@
import {
Injectable,
CanActivate,
NotFoundException,
ExecutionContext,
} from '@nestjs/common';
import { Injectable, CanActivate, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
@ -13,12 +8,8 @@ import {
GoogleAPIScopeConfig,
GoogleAPIsStrategy,
} from 'src/engine/core-modules/auth/strategies/google-apis.auth.strategy';
import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { getRequest } from 'src/utils/extract-request';
@Injectable()
export class GoogleAPIsProviderEnabledGuard implements CanActivate {
@ -29,7 +20,7 @@ export class GoogleAPIsProviderEnabledGuard implements CanActivate {
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
async canActivate(): Promise<boolean> {
if (
!this.environmentService.get('MESSAGING_PROVIDER_GMAIL_ENABLED') &&
!this.environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED')
@ -37,25 +28,12 @@ export class GoogleAPIsProviderEnabledGuard implements CanActivate {
throw new NotFoundException('Google apis auth is not enabled');
}
const transientToken = getRequest(context)?.query?.transientToken;
const scopeConfig: GoogleAPIScopeConfig = {
isCalendarEnabled: false,
isCalendarEnabled: !!this.environmentService.get(
'MESSAGING_PROVIDER_GMAIL_ENABLED',
),
};
if (transientToken && typeof transientToken === 'string') {
const { workspaceId } =
await this.tokenService.verifyTransientToken(transientToken);
const isCalendarEnabledFlag = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});
scopeConfig.isCalendarEnabled = !!isCalendarEnabledFlag?.value;
}
new GoogleAPIsStrategy(this.environmentService, scopeConfig);
return true;

View File

@ -5,10 +5,7 @@ import { Repository, EntityManager } from 'typeorm';
import { v4 } from 'uuid';
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
@ -76,15 +73,9 @@ export class GoogleAPIsService {
const workspaceDataSource =
await this.typeORMService.connectToDataSource(dataSourceMetadata);
const isCalendarEnabledFlag = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});
const isCalendarEnabled =
this.environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED') &&
!!isCalendarEnabledFlag?.value;
const isCalendarEnabled = this.environmentService.get(
'CALENDAR_PROVIDER_GOOGLE_ENABLED',
);
const connectedAccounts =
await this.connectedAccountRepository.getAllByHandleAndWorkspaceMemberId(

View File

@ -17,7 +17,6 @@ import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/
export enum FeatureFlagKeys {
IsBlocklistEnabled = 'IS_BLOCKLIST_ENABLED',
IsCalendarEnabled = 'IS_CALENDAR_ENABLED',
IsEventObjectEnabled = 'IS_EVENT_OBJECT_ENABLED',
IsAirtableIntegrationEnabled = 'IS_AIRTABLE_INTEGRATION_ENABLED',
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',