From 49b22e67843b1ec69cf75f71a90d9453087d1635 Mon Sep 17 00:00:00 2001 From: Richard Fontein <32132657+rifont@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:38:26 +0100 Subject: [PATCH] chore(api, worker): Remove multi provider feature flag (#4403) * chore(worker): Remove multi-provider FF * chore(worker): Remove ff from shared module * chore(api): Add API Readme * chore(api): Remove multi-provider FF from e2e tests * chore(api): Remove multi-provider FF usage from use-cases * chore(generic): Remove multi-provider FF from shared/generic * chore(api): Remove redundant disable-integration use-case * docs(api): Readme typo * test(api): Remove redundant describe block * fix: Remove redundant flag import in shared module --- apps/api/README.md | 82 +++++-------------- apps/api/src/.env.test | 1 - .../src/app/events/e2e/trigger-event.e2e.ts | 14 ---- .../e2e/create-integration.e2e.ts | 7 -- .../e2e/deactivate-integration.e2e.ts | 14 +--- .../e2e/get-active-integration.e2e.ts | 8 +- .../e2e/get-decrypted-integrations.e2e.ts | 7 -- .../integrations/e2e/get-integration.e2e.ts | 7 -- .../e2e/remove-integration.e2e.ts | 7 -- .../e2e/set-itegration-as-primary.e2e.ts | 7 -- .../e2e/update-integration.e2e.ts | 7 -- .../create-integration.usecase.ts | 37 +-------- .../deactivate-integration.command.ts | 11 --- .../deactivate-integration.usecase.ts | 40 --------- .../disable-novu-integration.command.ts | 13 --- .../disable-novu-integration.usecase.ts | 32 -------- .../src/app/integrations/usecases/index.ts | 4 - .../remove-integration.usecase.ts | 23 +----- .../set-integration-as-primary.usecase.ts | 20 +---- .../update-integration.usecase.ts | 33 +------- apps/api/src/app/shared/shared.module.ts | 2 - apps/worker/src/.env.test | 2 - apps/worker/src/app/shared/shared.module.ts | 2 - libs/shared/src/types/feature-flags/index.ts | 1 - .../src/custom-providers/index.ts | 15 ---- .../get-decrypted-integrations.usecase.ts | 22 +---- .../get-feature-flag/get-feature-flag.test.ts | 48 ----------- ...provider-configuration-enabled.use-case.ts | 27 ------ .../src/usecases/get-feature-flag/index.ts | 1 - .../select-integration.spec.ts | 12 +-- .../select-integration.usecase.ts | 36 +------- 31 files changed, 38 insertions(+), 504 deletions(-) delete mode 100644 apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.command.ts delete mode 100644 apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.usecase.ts delete mode 100644 apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.command.ts delete mode 100644 apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.usecase.ts delete mode 100644 packages/application-generic/src/usecases/get-feature-flag/get-is-multi-provider-configuration-enabled.use-case.ts diff --git a/apps/api/README.md b/apps/api/README.md index fa0d5361aed..f7f931edb5c 100644 --- a/apps/api/README.md +++ b/apps/api/README.md @@ -1,78 +1,38 @@ -

- Nest Logo -

+
+ + + + Logo + + +
-[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=main -[travis-url]: https://travis-ci.org/nestjs/nest -[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux -[linux-url]: https://travis-ci.org/nestjs/nest -

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

-

-NPM Version -Package License -NPM Downloads -Travis -Linux -Coverage -Gitter -Backers on Open Collective -Sponsors on Open Collective - - -

- +# @novu/api -## Description +A RESTful API for accessing the Novu platform, built using [NestJS](https://nestjs.com/). -[Nest](https://github.com/nestjs/nest) framework [TypeScript](https://www.typescriptlang.org/) starter repository. +## OpenAPI (formerly Swagger) -## Installation +The Novu API utilizes the [`@nestjs/swagger`](https://github.com/nestjs/swagger) package to generate up-to-date OpenAPI specifications. -```bash -$ npm install -``` +A web interface to browse the available endpoints is available at [api.novu.co/api](https://api.novu.co/api). An OpenAPI specification can be retrieved at [api.novu.co/api-json](https://api.novu.co/api-json). -## Running the app - -```bash -# development -$ npm run start +## Running the API -# watch mode -$ npm run start:dev +See the docs for [Run in Local Machine](https://docs.novu.co/community/run-in-local-machin) to get setup. Then run: -# incremental rebuild (webpack) -$ npm run webpack -$ npm run start:hmr - -# production mode -$ npm run start:prod +```bash +# Run the API in watch mode +$ npm run start:api ``` ## Test +### Unit Tests ```bash # unit tests $ npm run test - -# e2e tests -$ npm run test:e2e - -# test coverage -$ npm run test:cov ``` -## Support - -Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). - -## Stay in touch - -- Author - [Kamil Myƛliwiec](https://kamilmysliwiec.com) -- Website - [https://nestjs.com](https://nestjs.com/) -- Twitter - [@nestframework](https://twitter.com/nestframework) - -## License - -Nest is [MIT licensed](LICENSE). +### E2E tests +See the docs for [Running on Local Machine - API Tests](https://docs.novu.co/community/run-in-local-machine#api). diff --git a/apps/api/src/.env.test b/apps/api/src/.env.test index 5b43216c298..f8cc72206e5 100644 --- a/apps/api/src/.env.test +++ b/apps/api/src/.env.test @@ -74,7 +74,6 @@ VERCEL_REDIRECT_URI=http://localhost:4200/auth/login VERCEL_BASE_URL=https://api.vercel.com FF_IS_TOPIC_NOTIFICATION_ENABLED=true -IS_MULTI_PROVIDER_CONFIGURATION_ENABLED=true STORE_NOTIFICATION_CONTENT=true diff --git a/apps/api/src/app/events/e2e/trigger-event.e2e.ts b/apps/api/src/app/events/e2e/trigger-event.e2e.ts index c36242ed765..8d1eb8a7d2b 100644 --- a/apps/api/src/app/events/e2e/trigger-event.e2e.ts +++ b/apps/api/src/app/events/e2e/trigger-event.e2e.ts @@ -43,8 +43,6 @@ const axiosInstance = axios.create(); const eventTriggerPath = '/v1/events/trigger'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - const promiseTimeout = (ms: number): Promise => new Promise((resolve) => setTimeout(resolve, ms)); describe(`Trigger event - ${eventTriggerPath} (POST)`, function () { @@ -2389,18 +2387,6 @@ describe(`Trigger event - ${eventTriggerPath} (POST)`, function () { expect(messagesAfter.length).to.equal(1); }); }); - }); - describe.skip('Trigger Event - [IS_MULTI_PROVIDER_CONFIGURATION_ENABLED=true]', function () { - beforeEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - process.env.LAUNCH_DARKLY_SDK_KEY = ''; - session = new UserSession(); - await session.initialize(); - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - }); it('should trigger message with override integration identifier', async function () { const newSubscriberId = SubscriberRepository.createObjectId(); diff --git a/apps/api/src/app/integrations/e2e/create-integration.e2e.ts b/apps/api/src/app/integrations/e2e/create-integration.e2e.ts index 2700017dc1e..8d99417548d 100644 --- a/apps/api/src/app/integrations/e2e/create-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/create-integration.e2e.ts @@ -10,8 +10,6 @@ import { } from '@novu/shared'; import { expect } from 'chai'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Create Integration - /integration (POST)', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); @@ -20,11 +18,6 @@ describe('Create Integration - /integration (POST)', function () { beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('should get the email integration successfully', async function () { diff --git a/apps/api/src/app/integrations/e2e/deactivate-integration.e2e.ts b/apps/api/src/app/integrations/e2e/deactivate-integration.e2e.ts index 26219fc9725..605ade881a8 100644 --- a/apps/api/src/app/integrations/e2e/deactivate-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/deactivate-integration.e2e.ts @@ -1,29 +1,17 @@ import { IntegrationRepository } from '@novu/dal'; import { UserSession } from '@novu/testing'; import { expect } from 'chai'; -import * as sinon from 'sinon'; -import { GetIsMultiProviderConfigurationEnabled } from '@novu/application-generic'; describe('Deactivate Integration', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); - let stub: sinon.SinonStub; beforeEach(async () => { session = new UserSession(); - const service = session.testServer?.getService(GetIsMultiProviderConfigurationEnabled); - stub = sinon.stub(service, 'execute'); - stub.callsFake(() => { - return true; - }); await session.initialize(); }); - afterEach(() => { - stub.restore(); - }); - - it('should not deactivated old providers when feature flag is active', async function () { + it('should not deactivate old providers when a new provider is created', async function () { const payload = { providerId: 'mailgun', channel: 'email', diff --git a/apps/api/src/app/integrations/e2e/get-active-integration.e2e.ts b/apps/api/src/app/integrations/e2e/get-active-integration.e2e.ts index fd57cb55dd2..26c5ffafb56 100644 --- a/apps/api/src/app/integrations/e2e/get-active-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/get-active-integration.e2e.ts @@ -4,22 +4,16 @@ import { ChannelTypeEnum, EmailProviderIdEnum, SmsProviderIdEnum } from '@novu/s import { IntegrationService } from '@novu/testing'; import { IntegrationEntity } from '@novu/dal'; -describe('Get Active Integrations [IS_MULTI_PROVIDER_CONFIGURATION_ENABLED=true] - /integrations/active (GET)', function () { +describe('Get Active Integrations - Multi-Provider Configuration - /integrations/active (GET)', function () { let session: UserSession; const integrationService = new IntegrationService(); - const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; process.env.LAUNCH_DARKLY_SDK_KEY = ''; }); - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - }); - it('should get active integrations', async function () { await integrationService.createIntegration({ environmentId: session.environment._id, diff --git a/apps/api/src/app/integrations/e2e/get-decrypted-integrations.e2e.ts b/apps/api/src/app/integrations/e2e/get-decrypted-integrations.e2e.ts index 9810c383cd9..32aa7c4e916 100644 --- a/apps/api/src/app/integrations/e2e/get-decrypted-integrations.e2e.ts +++ b/apps/api/src/app/integrations/e2e/get-decrypted-integrations.e2e.ts @@ -3,8 +3,6 @@ import { expect } from 'chai'; import { ChannelTypeEnum, EmailProviderIdEnum } from '@novu/shared'; import { IntegrationRepository } from '@novu/dal'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Get Decrypted Integrations - /integrations (GET)', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); @@ -12,11 +10,6 @@ describe('Get Decrypted Integrations - /integrations (GET)', function () { beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('should get active decrypted integration', async function () { diff --git a/apps/api/src/app/integrations/e2e/get-integration.e2e.ts b/apps/api/src/app/integrations/e2e/get-integration.e2e.ts index 46786a848b1..a5594e9e24a 100644 --- a/apps/api/src/app/integrations/e2e/get-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/get-integration.e2e.ts @@ -3,19 +3,12 @@ import { expect } from 'chai'; import { ChannelTypeEnum, EmailProviderIdEnum, SmsProviderIdEnum } from '@novu/shared'; import { IntegrationEntity } from '@novu/dal'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Get Integrations - /integrations (GET)', function () { let session: UserSession; beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('should retrieve all the integrations of all environments from an organization from the prefilled test data', async () => { diff --git a/apps/api/src/app/integrations/e2e/remove-integration.e2e.ts b/apps/api/src/app/integrations/e2e/remove-integration.e2e.ts index 383df2a5fd5..797c5ee4e26 100644 --- a/apps/api/src/app/integrations/e2e/remove-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/remove-integration.e2e.ts @@ -10,8 +10,6 @@ import { } from '@novu/shared'; import { HttpStatus } from '@nestjs/common'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Delete Integration - /integration/:integrationId (DELETE)', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); @@ -19,11 +17,6 @@ describe('Delete Integration - /integration/:integrationId (DELETE)', function ( beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('should throw not found exception when integration is not found', async function () { diff --git a/apps/api/src/app/integrations/e2e/set-itegration-as-primary.e2e.ts b/apps/api/src/app/integrations/e2e/set-itegration-as-primary.e2e.ts index 05460670eea..4c2826347a6 100644 --- a/apps/api/src/app/integrations/e2e/set-itegration-as-primary.e2e.ts +++ b/apps/api/src/app/integrations/e2e/set-itegration-as-primary.e2e.ts @@ -9,8 +9,6 @@ import { PushProviderIdEnum, } from '@novu/shared'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Set Integration As Primary - /integrations/:integrationId/set-primary (POST)', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); @@ -18,11 +16,6 @@ describe('Set Integration As Primary - /integrations/:integrationId/set-primary beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('when integration id is not valid should throw bad request exception', async () => { diff --git a/apps/api/src/app/integrations/e2e/update-integration.e2e.ts b/apps/api/src/app/integrations/e2e/update-integration.e2e.ts index 96a176d296d..398193e68f1 100644 --- a/apps/api/src/app/integrations/e2e/update-integration.e2e.ts +++ b/apps/api/src/app/integrations/e2e/update-integration.e2e.ts @@ -10,8 +10,6 @@ import { PushProviderIdEnum, } from '@novu/shared'; -const ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - describe('Update Integration - /integrations/:integrationId (PUT)', function () { let session: UserSession; const integrationRepository = new IntegrationRepository(); @@ -20,11 +18,6 @@ describe('Update Integration - /integrations/:integrationId (PUT)', function () beforeEach(async () => { session = new UserSession(); await session.initialize(); - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - }); - - afterEach(async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ORIGINAL_IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; }); it('should throw not found exception when integration is not found', async function () { diff --git a/apps/api/src/app/integrations/usecases/create-integration/create-integration.usecase.ts b/apps/api/src/app/integrations/usecases/create-integration/create-integration.usecase.ts index 342a550998a..c7ae5a61749 100644 --- a/apps/api/src/app/integrations/usecases/create-integration/create-integration.usecase.ts +++ b/apps/api/src/app/integrations/usecases/create-integration/create-integration.usecase.ts @@ -15,13 +15,10 @@ import { encryptCredentials, buildIntegrationKey, InvalidateCacheService, - GetIsMultiProviderConfigurationEnabled, - FeatureFlagCommand, } from '@novu/application-generic'; import { CreateIntegrationCommand } from './create-integration.command'; import { ApiException } from '../../../shared/exceptions/api.exception'; -import { DeactivateSimilarChannelIntegrations } from '../deactivate-integration/deactivate-integration.usecase'; import { CheckIntegrationCommand } from '../check-integration/check-integration.command'; import { CheckIntegration } from '../check-integration/check-integration.usecase'; @@ -32,9 +29,7 @@ export class CreateIntegration { constructor( private invalidateCache: InvalidateCacheService, private integrationRepository: IntegrationRepository, - private deactivateSimilarChannelIntegrations: DeactivateSimilarChannelIntegrations, - private analyticsService: AnalyticsService, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled + private analyticsService: AnalyticsService ) {} private async calculatePriorityAndPrimary(command: CreateIntegrationCommand) { @@ -71,26 +66,12 @@ export class CreateIntegration { } async execute(command: CreateIntegrationCommand): Promise { - const isMultiProviderConfigurationEnabled = await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: command.organizationId, - environmentId: command.environmentId, - }) - ); - const existingIntegration = await this.integrationRepository.findOne({ _environmentId: command.environmentId, providerId: command.providerId, channel: command.channel, }); - if (!isMultiProviderConfigurationEnabled && existingIntegration) { - throw new BadRequestException( - 'Duplicate key - One environment may not have two providers of the same channel type' - ); - } - if ( existingIntegration && command.providerId === InAppProviderIdEnum.Novu && @@ -169,7 +150,7 @@ export class CreateIntegration { const isActiveAndChannelSupportsPrimary = command.active && CHANNELS_WITH_PRIMARY.includes(command.channel); - if (isMultiProviderConfigurationEnabled && isActiveAndChannelSupportsPrimary) { + if (isActiveAndChannelSupportsPrimary) { const { primary, priority } = await this.calculatePriorityAndPrimary(command); query.primary = primary; @@ -178,20 +159,6 @@ export class CreateIntegration { const integrationEntity = await this.integrationRepository.create(query); - if ( - !isMultiProviderConfigurationEnabled && - command.active && - ![ChannelTypeEnum.CHAT, ChannelTypeEnum.PUSH].includes(command.channel) - ) { - await this.deactivateSimilarChannelIntegrations.execute({ - environmentId: command.environmentId, - organizationId: command.organizationId, - integrationId: integrationEntity._id, - channel: command.channel, - userId: command.userId, - }); - } - return integrationEntity; } catch (e) { if (e instanceof DalException) { diff --git a/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.command.ts b/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.command.ts deleted file mode 100644 index fb0439c05dc..00000000000 --- a/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.command.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { IsDefined } from 'class-validator'; -import { ChannelTypeEnum } from '@novu/shared'; -import { EnvironmentWithUserCommand } from '../../../shared/commands/project.command'; - -export class DeactivateSimilarChannelIntegrationsCommand extends EnvironmentWithUserCommand { - @IsDefined() - integrationId: string; - - @IsDefined() - channel: ChannelTypeEnum; -} diff --git a/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.usecase.ts b/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.usecase.ts deleted file mode 100644 index 826b56a0c1a..00000000000 --- a/apps/api/src/app/integrations/usecases/deactivate-integration/deactivate-integration.usecase.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { IntegrationRepository } from '@novu/dal'; -import { FeatureFlagCommand, GetIsMultiProviderConfigurationEnabled } from '@novu/application-generic'; - -import { DeactivateSimilarChannelIntegrationsCommand } from './deactivate-integration.command'; - -@Injectable() -export class DeactivateSimilarChannelIntegrations { - constructor( - private integrationRepository: IntegrationRepository, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled - ) {} - async execute(command: DeactivateSimilarChannelIntegrationsCommand): Promise { - const shouldKeepIntegrationsActive = await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - environmentId: command.environmentId, - organizationId: command.organizationId, - userId: command.userId, - }) - ); - - if (shouldKeepIntegrationsActive) { - return; - } - - const otherExistedIntegration = await this.integrationRepository.find({ - _id: { $ne: command.integrationId }, - _environmentId: command.environmentId, - channel: command.channel, - active: true, - }); - - if (otherExistedIntegration.length) { - await this.integrationRepository.update( - { _environmentId: command.environmentId, _id: { $in: otherExistedIntegration.map((i) => i._id) } }, - { $set: { active: false } } - ); - } - } -} diff --git a/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.command.ts b/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.command.ts deleted file mode 100644 index 910278ffa31..00000000000 --- a/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.command.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ChannelTypeEnum } from '@novu/shared'; -import { IsDefined, IsEnum, IsString } from 'class-validator'; -import { EnvironmentWithUserCommand } from '../../../shared/commands/project.command'; - -export class DisableNovuIntegrationCommand extends EnvironmentWithUserCommand { - @IsDefined() - @IsEnum(ChannelTypeEnum) - channel: ChannelTypeEnum; - - @IsDefined() - @IsString() - providerId: string; -} diff --git a/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.usecase.ts b/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.usecase.ts deleted file mode 100644 index 7aaf7a346c4..00000000000 --- a/apps/api/src/app/integrations/usecases/disable-novu-integration/disable-novu-integration.usecase.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { IntegrationRepository } from '@novu/dal'; - -import { DisableNovuIntegrationCommand } from './disable-novu-integration.command'; -import { ChannelTypeEnum, EmailProviderIdEnum, ProvidersIdEnum, SmsProviderIdEnum } from '@novu/shared'; - -@Injectable() -export class DisableNovuIntegration { - private channelProviderIdMap = new Map(); - - constructor(private integrationRepository: IntegrationRepository) { - this.channelProviderIdMap.set(ChannelTypeEnum.EMAIL, EmailProviderIdEnum.Novu); - this.channelProviderIdMap.set(ChannelTypeEnum.SMS, SmsProviderIdEnum.Novu); - } - - async execute(command: DisableNovuIntegrationCommand): Promise { - const novuProviderId = this.channelProviderIdMap.get(command.channel); - - if (!novuProviderId) { - return; - } - - if (command.providerId === novuProviderId) { - return; - } - - await this.integrationRepository.update( - { _environmentId: command.environmentId, providerId: novuProviderId, channel: command.channel }, - { $set: { active: false, primary: false, priority: 0 } } - ); - } -} diff --git a/apps/api/src/app/integrations/usecases/index.ts b/apps/api/src/app/integrations/usecases/index.ts index 3a236504c10..e93e2fecdf3 100644 --- a/apps/api/src/app/integrations/usecases/index.ts +++ b/apps/api/src/app/integrations/usecases/index.ts @@ -10,14 +10,12 @@ import { CreateIntegration } from './create-integration/create-integration.useca import { GetIntegrations } from './get-integrations/get-integrations.usecase'; import { UpdateIntegration } from './update-integration/update-integration.usecase'; import { RemoveIntegration } from './remove-integration/remove-integration.usecase'; -import { DeactivateSimilarChannelIntegrations } from './deactivate-integration/deactivate-integration.usecase'; import { GetActiveIntegrations } from './get-active-integration/get-active-integration.usecase'; import { CheckIntegration } from './check-integration/check-integration.usecase'; import { CheckIntegrationEMail } from './check-integration/check-integration-email.usecase'; import { GetInAppActivated } from './get-in-app-activated/get-in-app-activated.usecase'; import { SetIntegrationAsPrimary } from './set-integration-as-primary/set-integration-as-primary.usecase'; import { CreateNovuIntegrations } from './create-novu-integrations/create-novu-integrations.usecase'; -import { DisableNovuIntegration } from './disable-novu-integration/disable-novu-integration.usecase'; export const USE_CASES = [ GetInAppActivated, @@ -30,11 +28,9 @@ export const USE_CASES = [ GetDecryptedIntegrations, UpdateIntegration, RemoveIntegration, - DeactivateSimilarChannelIntegrations, CheckIntegration, CheckIntegrationEMail, CalculateLimitNovuIntegration, SetIntegrationAsPrimary, CreateNovuIntegrations, - DisableNovuIntegration, ]; diff --git a/apps/api/src/app/integrations/usecases/remove-integration/remove-integration.usecase.ts b/apps/api/src/app/integrations/usecases/remove-integration/remove-integration.usecase.ts index 38c152ec264..6084be4cbb2 100644 --- a/apps/api/src/app/integrations/usecases/remove-integration/remove-integration.usecase.ts +++ b/apps/api/src/app/integrations/usecases/remove-integration/remove-integration.usecase.ts @@ -1,12 +1,7 @@ import { Injectable, NotFoundException, Scope } from '@nestjs/common'; import { IntegrationRepository, DalException } from '@novu/dal'; import { CHANNELS_WITH_PRIMARY } from '@novu/shared'; -import { - buildIntegrationKey, - FeatureFlagCommand, - GetIsMultiProviderConfigurationEnabled, - InvalidateCacheService, -} from '@novu/application-generic'; +import { buildIntegrationKey, InvalidateCacheService } from '@novu/application-generic'; import { RemoveIntegrationCommand } from './remove-integration.command'; import { ApiException } from '../../../shared/exceptions/api.exception'; @@ -15,11 +10,7 @@ import { ApiException } from '../../../shared/exceptions/api.exception'; scope: Scope.REQUEST, }) export class RemoveIntegration { - constructor( - private invalidateCache: InvalidateCacheService, - private integrationRepository: IntegrationRepository, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled - ) {} + constructor(private invalidateCache: InvalidateCacheService, private integrationRepository: IntegrationRepository) {} async execute(command: RemoveIntegrationCommand) { try { @@ -42,16 +33,8 @@ export class RemoveIntegration { _organizationId: existingIntegration._organizationId, }); - const isMultiProviderConfigurationEnabled = await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: command.organizationId, - environmentId: command.environmentId, - }) - ); - const isChannelSupportsPrimary = CHANNELS_WITH_PRIMARY.includes(existingIntegration.channel); - if (isMultiProviderConfigurationEnabled && isChannelSupportsPrimary) { + if (isChannelSupportsPrimary) { await this.integrationRepository.recalculatePriorityForAllActive({ _organizationId: existingIntegration._organizationId, _environmentId: existingIntegration._environmentId, diff --git a/apps/api/src/app/integrations/usecases/set-integration-as-primary/set-integration-as-primary.usecase.ts b/apps/api/src/app/integrations/usecases/set-integration-as-primary/set-integration-as-primary.usecase.ts index 88dd39d424f..316435be89c 100644 --- a/apps/api/src/app/integrations/usecases/set-integration-as-primary/set-integration-as-primary.usecase.ts +++ b/apps/api/src/app/integrations/usecases/set-integration-as-primary/set-integration-as-primary.usecase.ts @@ -1,13 +1,7 @@ import { Injectable, NotFoundException, Logger, BadRequestException } from '@nestjs/common'; import { IntegrationEntity, IntegrationRepository } from '@novu/dal'; import { CHANNELS_WITH_PRIMARY } from '@novu/shared'; -import { - AnalyticsService, - buildIntegrationKey, - FeatureFlagCommand, - GetIsMultiProviderConfigurationEnabled, - InvalidateCacheService, -} from '@novu/application-generic'; +import { AnalyticsService, buildIntegrationKey, InvalidateCacheService } from '@novu/application-generic'; import { SetIntegrationAsPrimaryCommand } from './set-integration-as-primary.command'; @@ -16,8 +10,7 @@ export class SetIntegrationAsPrimary { constructor( private invalidateCache: InvalidateCacheService, private integrationRepository: IntegrationRepository, - private analyticsService: AnalyticsService, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled + private analyticsService: AnalyticsService ) {} private async updatePrimaryFlag({ existingIntegration }: { existingIntegration: IntegrationEntity }) { @@ -68,14 +61,7 @@ export class SetIntegrationAsPrimary { } const { _organizationId, _environmentId, channel, providerId } = existingIntegration; - const isMultiProviderConfigurationEnabled = await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: _organizationId, - environmentId: _environmentId, - }) - ); - if (!isMultiProviderConfigurationEnabled || existingIntegration.primary) { + if (existingIntegration.primary) { return existingIntegration; } diff --git a/apps/api/src/app/integrations/usecases/update-integration/update-integration.usecase.ts b/apps/api/src/app/integrations/usecases/update-integration/update-integration.usecase.ts index 52c36906818..c36738cba9e 100644 --- a/apps/api/src/app/integrations/usecases/update-integration/update-integration.usecase.ts +++ b/apps/api/src/app/integrations/usecases/update-integration/update-integration.usecase.ts @@ -5,13 +5,10 @@ import { encryptCredentials, buildIntegrationKey, InvalidateCacheService, - GetIsMultiProviderConfigurationEnabled, - FeatureFlagCommand, } from '@novu/application-generic'; -import { ChannelTypeEnum, CHANNELS_WITH_PRIMARY } from '@novu/shared'; +import { CHANNELS_WITH_PRIMARY } from '@novu/shared'; import { UpdateIntegrationCommand } from './update-integration.command'; -import { DeactivateSimilarChannelIntegrations } from '../deactivate-integration/deactivate-integration.usecase'; import { CheckIntegration } from '../check-integration/check-integration.usecase'; import { CheckIntegrationCommand } from '../check-integration/check-integration.command'; @@ -22,9 +19,7 @@ export class UpdateIntegration { constructor( private invalidateCache: InvalidateCacheService, private integrationRepository: IntegrationRepository, - private deactivateSimilarChannelIntegrations: DeactivateSimilarChannelIntegrations, - private analyticsService: AnalyticsService, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled + private analyticsService: AnalyticsService ) {} private async calculatePriorityAndPrimaryForActive({ @@ -180,18 +175,10 @@ export class UpdateIntegration { throw new BadRequestException('No properties found for update'); } - const isMultiProviderConfigurationEnabled = await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: command.organizationId, - environmentId: command.userEnvironmentId, - }) - ); - const haveConditions = updatePayload.conditions && updatePayload.conditions?.length > 0; const isChannelSupportsPrimary = CHANNELS_WITH_PRIMARY.includes(existingIntegration.channel); - if (isMultiProviderConfigurationEnabled && isActiveChanged && isChannelSupportsPrimary) { + if (isActiveChanged && isChannelSupportsPrimary) { const { primary, priority } = await this.calculatePriorityAndPrimary({ existingIntegration, active: !!command.active, @@ -225,20 +212,6 @@ export class UpdateIntegration { }); } - if ( - !isMultiProviderConfigurationEnabled && - command.active && - ![ChannelTypeEnum.CHAT, ChannelTypeEnum.PUSH].includes(existingIntegration.channel) - ) { - await this.deactivateSimilarChannelIntegrations.execute({ - environmentId, - organizationId: command.organizationId, - integrationId: command.integrationId, - channel: existingIntegration.channel, - userId: command.userId, - }); - } - const updatedIntegration = await this.integrationRepository.findOne({ _id: command.integrationId, _environmentId: environmentId, diff --git a/apps/api/src/app/shared/shared.module.ts b/apps/api/src/app/shared/shared.module.ts index eadfc5b2318..ebd6c710093 100644 --- a/apps/api/src/app/shared/shared.module.ts +++ b/apps/api/src/app/shared/shared.module.ts @@ -32,7 +32,6 @@ import { DalServiceHealthIndicator, distributedLockService, featureFlagsService, - getIsMultiProviderConfigurationEnabled, getIsTopicNotificationEnabled, InvalidateCacheService, LoggerModule, @@ -85,7 +84,6 @@ const PROVIDERS = [ DalServiceHealthIndicator, distributedLockService, featureFlagsService, - getIsMultiProviderConfigurationEnabled, getIsTopicNotificationEnabled, InvalidateCacheService, storageService, diff --git a/apps/worker/src/.env.test b/apps/worker/src/.env.test index a8b0c8ee1ac..1ab03f2740d 100644 --- a/apps/worker/src/.env.test +++ b/apps/worker/src/.env.test @@ -72,5 +72,3 @@ LOGGING_LEVEL=error # Launch Darkly LAUNCH_DARKLY_SDK_KEY= - -IS_MULTI_PROVIDER_CONFIGURATION_ENABLED=true diff --git a/apps/worker/src/app/shared/shared.module.ts b/apps/worker/src/app/shared/shared.module.ts index c77e8bfa0c9..0472b2687d3 100644 --- a/apps/worker/src/app/shared/shared.module.ts +++ b/apps/worker/src/app/shared/shared.module.ts @@ -40,7 +40,6 @@ import { distributedLockService, EventsDistributedLockService, featureFlagsService, - getIsMultiProviderConfigurationEnabled, InvalidateCacheService, LoggerModule, ProcessSubscriber, @@ -111,7 +110,6 @@ const PROVIDERS = [ EventsDistributedLockService, featureFlagsService, getUseMergedDigestId, - getIsMultiProviderConfigurationEnabled, InvalidateCacheService, ProcessSubscriber, StorageHelperService, diff --git a/libs/shared/src/types/feature-flags/index.ts b/libs/shared/src/types/feature-flags/index.ts index ed8c8c97869..21ad0c4ee2c 100644 --- a/libs/shared/src/types/feature-flags/index.ts +++ b/libs/shared/src/types/feature-flags/index.ts @@ -1,7 +1,6 @@ export enum FeatureFlagsKeysEnum { IS_TEMPLATE_STORE_ENABLED = 'IS_TEMPLATE_STORE_ENABLED', IS_TOPIC_NOTIFICATION_ENABLED = 'IS_TOPIC_NOTIFICATION_ENABLED', - IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'IS_MULTI_PROVIDER_CONFIGURATION_ENABLED', IS_MULTI_TENANCY_ENABLED = 'IS_MULTI_TENANCY_ENABLED', IS_USE_MERGED_DIGEST_ID = 'IS_USE_MERGED_DIGEST_ID_ENABLED', } diff --git a/packages/application-generic/src/custom-providers/index.ts b/packages/application-generic/src/custom-providers/index.ts index 1a9c0a06ba7..f1a174be828 100644 --- a/packages/application-generic/src/custom-providers/index.ts +++ b/packages/application-generic/src/custom-providers/index.ts @@ -13,7 +13,6 @@ import { WorkflowQueueService, } from '../services'; import { - GetIsMultiProviderConfigurationEnabled, GetIsTopicNotificationEnabled, GetUseMergedDigestId, } from '../usecases'; @@ -41,20 +40,6 @@ export const getUseMergedDigestId = { inject: [FeatureFlagsService], }; -export const getIsMultiProviderConfigurationEnabled = { - provide: GetIsMultiProviderConfigurationEnabled, - useFactory: async ( - featureFlagServiceItem: FeatureFlagsService - ): Promise => { - const useCase = new GetIsMultiProviderConfigurationEnabled( - featureFlagServiceItem - ); - - return useCase; - }, - inject: [FeatureFlagsService], -}; - export const getIsTopicNotificationEnabled = { provide: GetIsTopicNotificationEnabled, useFactory: async ( diff --git a/packages/application-generic/src/usecases/get-decrypted-integrations/get-decrypted-integrations.usecase.ts b/packages/application-generic/src/usecases/get-decrypted-integrations/get-decrypted-integrations.usecase.ts index c4d7ad1cb2b..1216eb9e38c 100644 --- a/packages/application-generic/src/usecases/get-decrypted-integrations/get-decrypted-integrations.usecase.ts +++ b/packages/application-generic/src/usecases/get-decrypted-integrations/get-decrypted-integrations.usecase.ts @@ -3,38 +3,18 @@ import { IntegrationEntity, IntegrationRepository } from '@novu/dal'; import { decryptCredentials } from '../../encryption'; import { GetDecryptedIntegrationsCommand } from './get-decrypted-integrations.command'; -import { - FeatureFlagCommand, - GetIsMultiProviderConfigurationEnabled, -} from '../get-feature-flag'; @Injectable() export class GetDecryptedIntegrations { - constructor( - private integrationRepository: IntegrationRepository, - private getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled - ) {} + constructor(private integrationRepository: IntegrationRepository) {} async execute( command: GetDecryptedIntegrationsCommand ): Promise { - const isMultiProviderConfigurationEnabled = - await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: command.organizationId, - environmentId: command.environmentId, - }) - ); - const query: Partial & { _organizationId: string } = { _organizationId: command.organizationId, }; - if (command.environmentId && !isMultiProviderConfigurationEnabled) { - query._environmentId = command.environmentId; - } - if (command.active) { query.active = command.active; } diff --git a/packages/application-generic/src/usecases/get-feature-flag/get-feature-flag.test.ts b/packages/application-generic/src/usecases/get-feature-flag/get-feature-flag.test.ts index ace804a050f..c278401e575 100644 --- a/packages/application-generic/src/usecases/get-feature-flag/get-feature-flag.test.ts +++ b/packages/application-generic/src/usecases/get-feature-flag/get-feature-flag.test.ts @@ -1,5 +1,4 @@ import { - GetIsMultiProviderConfigurationEnabled, GetIsTemplateStoreEnabled, GetIsTopicNotificationEnabled, } from './index'; @@ -51,36 +50,6 @@ describe('Get Feature Flag', () => { }); }); - describe('IS_MULTI_PROVIDER_CONFIGURATION_ENABLED', () => { - it('should return default hardcoded value when no SDK env is set and no feature flag is set', async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = ''; - - const getIsMultiProviderConfigurationEnabled = - new GetIsMultiProviderConfigurationEnabled( - new FeatureFlagsService() - ); - - const result = await getIsMultiProviderConfigurationEnabled.execute( - featureFlagCommand - ); - expect(result).toEqual(false); - }); - - it('should return env variable value when no SDK env is set but the feature flag is set', async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'true'; - - const getIsMultiProviderConfigurationEnabled = - new GetIsMultiProviderConfigurationEnabled( - new FeatureFlagsService() - ); - - const result = await getIsMultiProviderConfigurationEnabled.execute( - featureFlagCommand - ); - expect(result).toEqual(true); - }); - }); - describe('IS_TOPIC_NOTIFICATION_ENABLED', () => { it('should return default hardcoded value when no SDK env is set and no feature flag is set', async () => { process.env.FF_IS_TOPIC_NOTIFICATION_ENABLED = ''; @@ -135,23 +104,6 @@ describe('Get Feature Flag', () => { }); }); - describe('IS_MULTI_PROVIDER_CONFIGURATION_ENABLED', () => { - it(`should get the feature flag value stored in Launch Darkly (enabled) - when the SDK key env variable is set regardless of the feature flag set`, async () => { - process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'false'; - - const getIsMultiProviderConfigurationEnabled = - new GetIsMultiProviderConfigurationEnabled( - new FeatureFlagsService() - ); - - const result = await getIsMultiProviderConfigurationEnabled.execute( - featureFlagCommand - ); - expect(result).toEqual(true); - }); - }); - describe('IS_TOPIC_NOTIFICATION_ENABLED', () => { it(`should get the feature flag value stored in Launch Darkly (enabled) when the SDK key env variable is set regardless of the feature flag set`, async () => { diff --git a/packages/application-generic/src/usecases/get-feature-flag/get-is-multi-provider-configuration-enabled.use-case.ts b/packages/application-generic/src/usecases/get-feature-flag/get-is-multi-provider-configuration-enabled.use-case.ts deleted file mode 100644 index 38e2ddc8c08..00000000000 --- a/packages/application-generic/src/usecases/get-feature-flag/get-is-multi-provider-configuration-enabled.use-case.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { FeatureFlagsKeysEnum } from '@novu/shared'; - -import { - GetFeatureFlagCommand, - FeatureFlagCommand, -} from './get-feature-flag.command'; -import { GetFeatureFlag } from './get-feature-flag.use-case'; - -const LOG_CONTEXT = 'GetIsMultiProviderConfigurationEnabled'; - -@Injectable() -export class GetIsMultiProviderConfigurationEnabled extends GetFeatureFlag { - async execute(featureFlagCommand: FeatureFlagCommand): Promise { - const value = process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - const fallbackValue = false; - const defaultValue = this.prepareBooleanStringFeatureFlag( - value, - fallbackValue - ); - const key = FeatureFlagsKeysEnum.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED; - - const command = this.buildCommand(key, defaultValue, featureFlagCommand); - - return await this.featureFlagsService.getWithContext(command); - } -} diff --git a/packages/application-generic/src/usecases/get-feature-flag/index.ts b/packages/application-generic/src/usecases/get-feature-flag/index.ts index 97389067676..71a53d54ece 100644 --- a/packages/application-generic/src/usecases/get-feature-flag/index.ts +++ b/packages/application-generic/src/usecases/get-feature-flag/index.ts @@ -4,7 +4,6 @@ export { } from './get-feature-flag.command'; export { GetFeatureFlag } from './get-feature-flag.use-case'; export { GetIsInMemoryClusterModeEnabled } from './get-is-in-memory-cluster-mode-enabled.use-case'; -export { GetIsMultiProviderConfigurationEnabled } from './get-is-multi-provider-configuration-enabled.use-case'; export { GetIsTemplateStoreEnabled } from './get-is-template-store-enabled.use-case'; export { GetIsTopicNotificationEnabled } from './get-is-topic-notification-enabled.use-case'; export { GetUseMergedDigestId } from './get-use-merged-digest-id.use-case'; diff --git a/packages/application-generic/src/usecases/select-integration/select-integration.spec.ts b/packages/application-generic/src/usecases/select-integration/select-integration.spec.ts index 58b6e43fe11..f976e9d4891 100644 --- a/packages/application-generic/src/usecases/select-integration/select-integration.spec.ts +++ b/packages/application-generic/src/usecases/select-integration/select-integration.spec.ts @@ -8,7 +8,6 @@ import { import { SelectIntegration } from './select-integration.usecase'; import { SelectIntegrationCommand } from './select-integration.command'; -import { GetIsMultiProviderConfigurationEnabled } from '../get-feature-flag'; import { GetDecryptedIntegrations } from '../get-decrypted-integrations'; import { ConditionsFilter } from '../conditions-filter'; @@ -73,13 +72,6 @@ jest.mock('@novu/dal', () => ({ })), })); -jest.mock('../get-feature-flag', () => ({ - ...jest.requireActual('../get-feature-flag'), - GetIsMultiProviderConfigurationEnabled: jest.fn(() => ({ - execute: jest.fn(() => true), - })), -})); - jest.mock('../get-decrypted-integrations', () => ({ ...jest.requireActual('../get-decrypted-integrations'), GetDecryptedIntegrations: jest.fn(() => ({ @@ -97,9 +89,7 @@ describe('select integration', function () { // @ts-ignore new GetDecryptedIntegrations(), new ConditionsFilter(), - new TenantRepository(), - // @ts-ignore - new GetIsMultiProviderConfigurationEnabled() + new TenantRepository() ); jest.clearAllMocks(); }); diff --git a/packages/application-generic/src/usecases/select-integration/select-integration.usecase.ts b/packages/application-generic/src/usecases/select-integration/select-integration.usecase.ts index 20591a9d668..f965326a230 100644 --- a/packages/application-generic/src/usecases/select-integration/select-integration.usecase.ts +++ b/packages/application-generic/src/usecases/select-integration/select-integration.usecase.ts @@ -10,14 +10,7 @@ import { CHANNELS_WITH_PRIMARY } from '@novu/shared'; import { SelectIntegrationCommand } from './select-integration.command'; import { ConditionsFilter } from '../conditions-filter/conditions-filter.usecase'; import { buildIntegrationKey, CachedQuery } from '../../services/cache'; -import { - FeatureFlagCommand, - GetIsMultiProviderConfigurationEnabled, -} from '../get-feature-flag'; -import { - GetDecryptedIntegrations, - GetDecryptedIntegrationsCommand, -} from '../get-decrypted-integrations'; +import { GetDecryptedIntegrations } from '../get-decrypted-integrations'; import { ConditionsFilterCommand } from '../conditions-filter'; const LOG_CONTEXT = 'SelectIntegration'; @@ -28,8 +21,7 @@ export class SelectIntegration { private integrationRepository: IntegrationRepository, protected getDecryptedIntegrationsUsecase: GetDecryptedIntegrations, protected conditionsFilter: ConditionsFilter, - private tenantRepository: TenantRepository, - protected getIsMultiProviderConfigurationEnabled: GetIsMultiProviderConfigurationEnabled + private tenantRepository: TenantRepository ) {} @CachedQuery({ @@ -42,30 +34,6 @@ export class SelectIntegration { async execute( command: SelectIntegrationCommand ): Promise { - const isMultiProviderConfigurationEnabled = - await this.getIsMultiProviderConfigurationEnabled.execute( - FeatureFlagCommand.create({ - userId: command.userId, - organizationId: command.organizationId, - environmentId: command.environmentId, - }) - ); - - if (!isMultiProviderConfigurationEnabled) { - const integrations = await this.getDecryptedIntegrationsUsecase.execute( - GetDecryptedIntegrationsCommand.create({ - organizationId: command.organizationId, - environmentId: command.environmentId, - channelType: command.channelType, - findOne: true, - active: true, - userId: command.userId, - }) - ); - - return integrations[0]; - } - let integration: IntegrationEntity | null = await this.getPrimaryIntegration(command);