From 80c9ebfd4ec1cbaaf4fabbb123590daae76ad635 Mon Sep 17 00:00:00 2001 From: martmull Date: Wed, 22 Jan 2025 15:53:40 +0100 Subject: [PATCH] Remove isGmailSendEmailScopeEnabled featureFlag (#9787) as title --- .../src/generated-metadata/graphql.ts | 127 +++++++++++----- .../twenty-front/src/generated/graphql.tsx | 137 ++++++++++++------ .../src/testing/mock-data/config.ts | 4 +- .../typeorm-seeds/core/feature-flags.ts | 5 - ...pis-oauth-exchange-code-for-token.guard.ts | 19 +-- .../google-apis-oauth-request-code.guard.ts | 12 +- .../auth/services/google-apis.service.ts | 10 +- .../google-apis-oauth-common.auth.strategy.ts | 3 +- ...h-exchange-code-for-token.auth.strategy.ts | 3 +- ...e-apis-oauth-request-code.auth.strategy.ts | 3 +- .../utils/get-google-apis-oauth-scopes.ts | 13 +- .../enums/feature-flag-key.enum.ts | 1 - 12 files changed, 196 insertions(+), 141 deletions(-) diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.ts index 18a4b164a..e243f4ff7 100644 --- a/packages/twenty-front/src/generated-metadata/graphql.ts +++ b/packages/twenty-front/src/generated-metadata/graphql.ts @@ -119,7 +119,7 @@ export type Billing = { __typename?: 'Billing'; billingUrl?: Maybe; isBillingEnabled: Scalars['Boolean']['output']; - trialPeriods: Array; + trialPeriods: Array; }; /** The different billing plans available */ @@ -128,6 +128,72 @@ export enum BillingPlanKey { PRO = 'PRO' } +export type BillingPlanOutput = { + __typename?: 'BillingPlanOutput'; + baseProduct: BillingProductDto; + meteredProducts: Array; + otherLicensedProducts: Array; + planKey: BillingPlanKey; +}; + +export type BillingPriceLicensedDto = { + __typename?: 'BillingPriceLicensedDTO'; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']['output']; + unitAmount: Scalars['Float']['output']; +}; + +export type BillingPriceMeteredDto = { + __typename?: 'BillingPriceMeteredDTO'; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']['output']; + tiers?: Maybe>; + tiersMode?: Maybe; +}; + +export type BillingPriceTierDto = { + __typename?: 'BillingPriceTierDTO'; + flatAmount?: Maybe; + unitAmount?: Maybe; + upTo?: Maybe; +}; + +/** The different billing price tiers modes */ +export enum BillingPriceTiersMode { + GRADUATED = 'GRADUATED', + VOLUME = 'VOLUME' +} + +export type BillingPriceUnionDto = BillingPriceLicensedDto | BillingPriceMeteredDto; + +export type BillingProductDto = { + __typename?: 'BillingProductDTO'; + description: Scalars['String']['output']; + images?: Maybe>; + name: Scalars['String']['output']; + prices: Array>; + type: BillingUsageType; +}; + +export type BillingProductPriceDto = { + __typename?: 'BillingProductPriceDTO'; + created: Scalars['Float']['output']; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']['output']; + unitAmount: Scalars['Float']['output']; +}; + +export type BillingProductPricesOutput = { + __typename?: 'BillingProductPricesOutput'; + productPrices: Array; + totalNumberOfPrices: Scalars['Int']['output']; +}; + +export type BillingSessionOutput = { + __typename?: 'BillingSessionOutput'; + url?: Maybe; +}; + export type BillingSubscription = { __typename?: 'BillingSubscription'; id: Scalars['UUID']['output']; @@ -135,6 +201,23 @@ export type BillingSubscription = { status: SubscriptionStatus; }; +export type BillingTrialPeriodDto = { + __typename?: 'BillingTrialPeriodDTO'; + duration: Scalars['Float']['output']; + isCreditCardRequired: Scalars['Boolean']['output']; +}; + +export type BillingUpdateOutput = { + __typename?: 'BillingUpdateOutput'; + /** Boolean that confirms query was successful */ + success: Scalars['Boolean']['output']; +}; + +export enum BillingUsageType { + LICENSED = 'LICENSED', + METERED = 'METERED' +} + export type BooleanFieldComparison = { is?: InputMaybe; isNot?: InputMaybe; @@ -372,12 +455,12 @@ export enum FeatureFlagKey { IsAdvancedFiltersEnabled = 'IsAdvancedFiltersEnabled', IsAirtableIntegrationEnabled = 'IsAirtableIntegrationEnabled', IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled', + IsBillingPlansEnabled = 'IsBillingPlansEnabled', IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled', IsCopilotEnabled = 'IsCopilotEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsFreeAccessEnabled = 'IsFreeAccessEnabled', IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled', - IsGmailSendEmailScopeEnabled = 'IsGmailSendEmailScopeEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', IsLocalizationEnabled = 'IsLocalizationEnabled', IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled', @@ -548,7 +631,7 @@ export type Mutation = { activateWorkspace: Workspace; authorizeApp: AuthorizeApp; challenge: LoginToken; - checkoutSession: SessionEntity; + checkoutSession: BillingSessionOutput; computeStepOutputSchema: Scalars['JSON']['output']; createDraftFromWorkflowVersion: WorkflowVersion; createOIDCIdentityProvider: SetupSsoOutput; @@ -593,7 +676,7 @@ export type Mutation = { syncRemoteTableSchemaChanges: RemoteTable; track: Analytics; unsyncRemoteTable: RemoteTable; - updateBillingSubscription: UpdateBillingEntity; + updateBillingSubscription: BillingUpdateOutput; updateLabPublicFeatureFlag: Scalars['Boolean']['output']; updateOneField: Field; updateOneObject: Object; @@ -982,20 +1065,6 @@ export type PostgresCredentials = { workspaceId: Scalars['String']['output']; }; -export type ProductPriceEntity = { - __typename?: 'ProductPriceEntity'; - created: Scalars['Float']['output']; - recurringInterval: SubscriptionInterval; - stripePriceId: Scalars['String']['output']; - unitAmount: Scalars['Float']['output']; -}; - -export type ProductPricesEntity = { - __typename?: 'ProductPricesEntity'; - productPrices: Array; - totalNumberOfPrices: Scalars['Int']['output']; -}; - export type PublicFeatureFlag = { __typename?: 'PublicFeatureFlag'; key: FeatureFlagKey; @@ -1025,7 +1094,7 @@ export type PublishServerlessFunctionInput = { export type Query = { __typename?: 'Query'; - billingPortalSession: SessionEntity; + billingPortalSession: BillingSessionOutput; checkUserExists: UserExistsOutput; checkWorkspaceInviteHashIsValid: WorkspaceInviteHashValid; clientConfig: ClientConfig; @@ -1043,7 +1112,7 @@ export type Query = { findWorkspaceInvitations: Array; getAvailablePackages: Scalars['JSON']['output']; getPostgresCredentials?: Maybe; - getProductPrices: ProductPricesEntity; + getProductPrices: BillingProductPricesOutput; getPublicWorkspaceDataBySubdomain: PublicWorkspaceDataOutput; getServerlessFunctionSourceCode?: Maybe; getTimelineCalendarEventsFromCompanyId: TimelineCalendarEventsWithTotal; @@ -1055,6 +1124,7 @@ export type Query = { listSSOIdentityProvidersByWorkspaceId: Array; object: Object; objects: ObjectConnection; + plans: Array; relation: Relation; relations: RelationConnection; validatePasswordResetToken: ValidatePasswordResetToken; @@ -1368,11 +1438,6 @@ export enum ServerlessFunctionSyncStatus { READY = 'READY' } -export type SessionEntity = { - __typename?: 'SessionEntity'; - url?: Maybe; -}; - export type SetupOidcSsoInput = { clientID: Scalars['String']['input']; clientSecret: Scalars['String']['input']; @@ -1497,12 +1562,6 @@ export type TransientToken = { transientToken: AuthToken; }; -export type TrialPeriodDto = { - __typename?: 'TrialPeriodDTO'; - duration: Scalars['Float']['output']; - isCreditCardRequired: Scalars['Boolean']['output']; -}; - export type UuidFilterComparison = { eq?: InputMaybe; gt?: InputMaybe; @@ -1520,12 +1579,6 @@ export type UuidFilterComparison = { notLike?: InputMaybe; }; -export type UpdateBillingEntity = { - __typename?: 'UpdateBillingEntity'; - /** Boolean that confirms query was successful */ - success: Scalars['Boolean']['output']; -}; - export type UpdateFieldInput = { defaultValue?: InputMaybe; description?: InputMaybe; diff --git a/packages/twenty-front/src/generated/graphql.tsx b/packages/twenty-front/src/generated/graphql.tsx index 7a9b6d25b..54fc0c64c 100644 --- a/packages/twenty-front/src/generated/graphql.tsx +++ b/packages/twenty-front/src/generated/graphql.tsx @@ -112,7 +112,7 @@ export type Billing = { __typename?: 'Billing'; billingUrl?: Maybe; isBillingEnabled: Scalars['Boolean']; - trialPeriods: Array; + trialPeriods: Array; }; /** The different billing plans available */ @@ -121,6 +121,72 @@ export enum BillingPlanKey { PRO = 'PRO' } +export type BillingPlanOutput = { + __typename?: 'BillingPlanOutput'; + baseProduct: BillingProductDto; + meteredProducts: Array; + otherLicensedProducts: Array; + planKey: BillingPlanKey; +}; + +export type BillingPriceLicensedDto = { + __typename?: 'BillingPriceLicensedDTO'; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']; + unitAmount: Scalars['Float']; +}; + +export type BillingPriceMeteredDto = { + __typename?: 'BillingPriceMeteredDTO'; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']; + tiers?: Maybe>; + tiersMode?: Maybe; +}; + +export type BillingPriceTierDto = { + __typename?: 'BillingPriceTierDTO'; + flatAmount?: Maybe; + unitAmount?: Maybe; + upTo?: Maybe; +}; + +/** The different billing price tiers modes */ +export enum BillingPriceTiersMode { + GRADUATED = 'GRADUATED', + VOLUME = 'VOLUME' +} + +export type BillingPriceUnionDto = BillingPriceLicensedDto | BillingPriceMeteredDto; + +export type BillingProductDto = { + __typename?: 'BillingProductDTO'; + description: Scalars['String']; + images?: Maybe>; + name: Scalars['String']; + prices: Array>; + type: BillingUsageType; +}; + +export type BillingProductPriceDto = { + __typename?: 'BillingProductPriceDTO'; + created: Scalars['Float']; + recurringInterval: SubscriptionInterval; + stripePriceId: Scalars['String']; + unitAmount: Scalars['Float']; +}; + +export type BillingProductPricesOutput = { + __typename?: 'BillingProductPricesOutput'; + productPrices: Array; + totalNumberOfPrices: Scalars['Int']; +}; + +export type BillingSessionOutput = { + __typename?: 'BillingSessionOutput'; + url?: Maybe; +}; + export type BillingSubscription = { __typename?: 'BillingSubscription'; id: Scalars['UUID']; @@ -128,6 +194,23 @@ export type BillingSubscription = { status: SubscriptionStatus; }; +export type BillingTrialPeriodDto = { + __typename?: 'BillingTrialPeriodDTO'; + duration: Scalars['Float']; + isCreditCardRequired: Scalars['Boolean']; +}; + +export type BillingUpdateOutput = { + __typename?: 'BillingUpdateOutput'; + /** Boolean that confirms query was successful */ + success: Scalars['Boolean']; +}; + +export enum BillingUsageType { + LICENSED = 'LICENSED', + METERED = 'METERED' +} + export type BooleanFieldComparison = { is?: InputMaybe; isNot?: InputMaybe; @@ -304,12 +387,12 @@ export enum FeatureFlagKey { IsAdvancedFiltersEnabled = 'IsAdvancedFiltersEnabled', IsAirtableIntegrationEnabled = 'IsAirtableIntegrationEnabled', IsAnalyticsV2Enabled = 'IsAnalyticsV2Enabled', + IsBillingPlansEnabled = 'IsBillingPlansEnabled', IsCommandMenuV2Enabled = 'IsCommandMenuV2Enabled', IsCopilotEnabled = 'IsCopilotEnabled', IsEventObjectEnabled = 'IsEventObjectEnabled', IsFreeAccessEnabled = 'IsFreeAccessEnabled', IsFunctionSettingsEnabled = 'IsFunctionSettingsEnabled', - IsGmailSendEmailScopeEnabled = 'IsGmailSendEmailScopeEnabled', IsJsonFilterEnabled = 'IsJsonFilterEnabled', IsLocalizationEnabled = 'IsLocalizationEnabled', IsMicrosoftSyncEnabled = 'IsMicrosoftSyncEnabled', @@ -473,7 +556,7 @@ export type Mutation = { activateWorkspace: Workspace; authorizeApp: AuthorizeApp; challenge: LoginToken; - checkoutSession: SessionEntity; + checkoutSession: BillingSessionOutput; computeStepOutputSchema: Scalars['JSON']; createDraftFromWorkflowVersion: WorkflowVersion; createOIDCIdentityProvider: SetupSsoOutput; @@ -511,7 +594,7 @@ export type Mutation = { signUp: SignUpOutput; skipSyncEmailOnboardingStep: OnboardingStepSuccess; track: Analytics; - updateBillingSubscription: UpdateBillingEntity; + updateBillingSubscription: BillingUpdateOutput; updateLabPublicFeatureFlag: Scalars['Boolean']; updateOneField: Field; updateOneObject: Object; @@ -849,20 +932,6 @@ export type PostgresCredentials = { workspaceId: Scalars['String']; }; -export type ProductPriceEntity = { - __typename?: 'ProductPriceEntity'; - created: Scalars['Float']; - recurringInterval: SubscriptionInterval; - stripePriceId: Scalars['String']; - unitAmount: Scalars['Float']; -}; - -export type ProductPricesEntity = { - __typename?: 'ProductPricesEntity'; - productPrices: Array; - totalNumberOfPrices: Scalars['Int']; -}; - export type PublicFeatureFlag = { __typename?: 'PublicFeatureFlag'; key: FeatureFlagKey; @@ -892,7 +961,7 @@ export type PublishServerlessFunctionInput = { export type Query = { __typename?: 'Query'; - billingPortalSession: SessionEntity; + billingPortalSession: BillingSessionOutput; checkUserExists: UserExistsOutput; checkWorkspaceInviteHashIsValid: WorkspaceInviteHashValid; clientConfig: ClientConfig; @@ -907,7 +976,7 @@ export type Query = { findWorkspaceInvitations: Array; getAvailablePackages: Scalars['JSON']; getPostgresCredentials?: Maybe; - getProductPrices: ProductPricesEntity; + getProductPrices: BillingProductPricesOutput; getPublicWorkspaceDataBySubdomain: PublicWorkspaceDataOutput; getServerlessFunctionSourceCode?: Maybe; getTimelineCalendarEventsFromCompanyId: TimelineCalendarEventsWithTotal; @@ -919,6 +988,7 @@ export type Query = { listSSOIdentityProvidersByWorkspaceId: Array; object: Object; objects: ObjectConnection; + plans: Array; validatePasswordResetToken: ValidatePasswordResetToken; }; @@ -1158,11 +1228,6 @@ export enum ServerlessFunctionSyncStatus { READY = 'READY' } -export type SessionEntity = { - __typename?: 'SessionEntity'; - url?: Maybe; -}; - export type SetupOidcSsoInput = { clientID: Scalars['String']; clientSecret: Scalars['String']; @@ -1287,12 +1352,6 @@ export type TransientToken = { transientToken: AuthToken; }; -export type TrialPeriodDto = { - __typename?: 'TrialPeriodDTO'; - duration: Scalars['Float']; - isCreditCardRequired: Scalars['Boolean']; -}; - export type UuidFilterComparison = { eq?: InputMaybe; gt?: InputMaybe; @@ -1310,12 +1369,6 @@ export type UuidFilterComparison = { notLike?: InputMaybe; }; -export type UpdateBillingEntity = { - __typename?: 'UpdateBillingEntity'; - /** Boolean that confirms query was successful */ - success: Scalars['Boolean']; -}; - export type UpdateFieldInput = { defaultValue?: InputMaybe; description?: InputMaybe; @@ -1988,7 +2041,7 @@ export type BillingPortalSessionQueryVariables = Exact<{ }>; -export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'SessionEntity', url?: string | null } }; +export type BillingPortalSessionQuery = { __typename?: 'Query', billingPortalSession: { __typename?: 'BillingSessionOutput', url?: string | null } }; export type CheckoutSessionMutationVariables = Exact<{ recurringInterval: SubscriptionInterval; @@ -1998,24 +2051,24 @@ export type CheckoutSessionMutationVariables = Exact<{ }>; -export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'SessionEntity', url?: string | null } }; +export type CheckoutSessionMutation = { __typename?: 'Mutation', checkoutSession: { __typename?: 'BillingSessionOutput', url?: string | null } }; export type GetProductPricesQueryVariables = Exact<{ product: Scalars['String']; }>; -export type GetProductPricesQuery = { __typename?: 'Query', getProductPrices: { __typename?: 'ProductPricesEntity', productPrices: Array<{ __typename?: 'ProductPriceEntity', created: number, recurringInterval: SubscriptionInterval, stripePriceId: string, unitAmount: number }> } }; +export type GetProductPricesQuery = { __typename?: 'Query', getProductPrices: { __typename?: 'BillingProductPricesOutput', productPrices: Array<{ __typename?: 'BillingProductPriceDTO', created: number, recurringInterval: SubscriptionInterval, stripePriceId: string, unitAmount: number }> } }; export type UpdateBillingSubscriptionMutationVariables = Exact<{ [key: string]: never; }>; -export type UpdateBillingSubscriptionMutation = { __typename?: 'Mutation', updateBillingSubscription: { __typename?: 'UpdateBillingEntity', success: boolean } }; +export type UpdateBillingSubscriptionMutation = { __typename?: 'Mutation', updateBillingSubscription: { __typename?: 'BillingUpdateOutput', success: boolean } }; export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>; -export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, isMultiWorkspaceEnabled: boolean, isEmailVerificationRequired: boolean, defaultSubdomain?: string | null, frontDomain: string, debugMode: boolean, analyticsEnabled: boolean, chromeExtensionId?: string | null, canManageFeatureFlags: boolean, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, trialPeriods: Array<{ __typename?: 'TrialPeriodDTO', duration: number, isCreditCardRequired: boolean }> }, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean, sso: Array<{ __typename?: 'SSOIdentityProvider', id: string, name: string, type: IdentityProviderType, status: SsoIdentityProviderStatus, issuer: string }> }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number }, publicFeatureFlags: Array<{ __typename?: 'PublicFeatureFlag', key: FeatureFlagKey, metadata: { __typename?: 'PublicFeatureFlagMetadata', label: string, description: string, imagePath: string } }> } }; +export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, isMultiWorkspaceEnabled: boolean, isEmailVerificationRequired: boolean, defaultSubdomain?: string | null, frontDomain: string, debugMode: boolean, analyticsEnabled: boolean, chromeExtensionId?: string | null, canManageFeatureFlags: boolean, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, trialPeriods: Array<{ __typename?: 'BillingTrialPeriodDTO', duration: number, isCreditCardRequired: boolean }> }, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean, sso: Array<{ __typename?: 'SSOIdentityProvider', id: string, name: string, type: IdentityProviderType, status: SsoIdentityProviderStatus, issuer: string }> }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number }, publicFeatureFlags: Array<{ __typename?: 'PublicFeatureFlag', key: FeatureFlagKey, metadata: { __typename?: 'PublicFeatureFlagMetadata', label: string, description: string, imagePath: string } }> } }; export type SkipSyncEmailOnboardingStepMutationVariables = Exact<{ [key: string]: never; }>; diff --git a/packages/twenty-front/src/testing/mock-data/config.ts b/packages/twenty-front/src/testing/mock-data/config.ts index fdd091d7c..6c91c6caf 100644 --- a/packages/twenty-front/src/testing/mock-data/config.ts +++ b/packages/twenty-front/src/testing/mock-data/config.ts @@ -33,12 +33,12 @@ export const mockedClientConfig: ClientConfig = { billingUrl: '', trialPeriods: [ { - __typename: 'TrialPeriodDTO', + __typename: 'BillingTrialPeriodDTO', duration: 30, isCreditCardRequired: true, }, { - __typename: 'TrialPeriodDTO', + __typename: 'BillingTrialPeriodDTO', duration: 7, isCreditCardRequired: false, }, diff --git a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts index fd7da0e98..976cbd980 100644 --- a/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts +++ b/packages/twenty-server/src/database/typeorm-seeds/core/feature-flags.ts @@ -55,11 +55,6 @@ export const seedFeatureFlags = async ( workspaceId: workspaceId, value: true, }, - { - key: FeatureFlagKey.IsGmailSendEmailScopeEnabled, - workspaceId: workspaceId, - value: true, - }, { key: FeatureFlagKey.IsUniqueIndexesEnabled, workspaceId: workspaceId, diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts index 7d3e1c324..ea984e8eb 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-exchange-code-for-token.guard.ts @@ -6,36 +6,20 @@ import { AuthExceptionCode, } from 'src/engine/core-modules/auth/auth.exception'; import { GoogleAPIsOauthExchangeCodeForTokenStrategy } from 'src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy'; -import { TransientTokenService } from 'src/engine/core-modules/auth/token/services/transient-token.service'; import { setRequestExtraParams } from 'src/engine/core-modules/auth/utils/google-apis-set-request-extra-params.util'; import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; -import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; -import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service'; @Injectable() export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard( 'google-apis', ) { - constructor( - private readonly environmentService: EnvironmentService, - private readonly featureFlagService: FeatureFlagService, - private readonly transientTokenService: TransientTokenService, - ) { + constructor(private readonly environmentService: EnvironmentService) { super(); } async canActivate(context: ExecutionContext) { const request = context.switchToHttp().getRequest(); const state = JSON.parse(request.query.state); - const { workspaceId } = - await this.transientTokenService.verifyTransientToken( - state.transientToken, - ); - const isGmailSendEmailScopeEnabled = - await this.featureFlagService.isFeatureEnabled( - FeatureFlagKey.IsGmailSendEmailScopeEnabled, - workspaceId, - ); if ( !this.environmentService.get('MESSAGING_PROVIDER_GMAIL_ENABLED') && @@ -50,7 +34,6 @@ export class GoogleAPIsOauthExchangeCodeForTokenGuard extends AuthGuard( new GoogleAPIsOauthExchangeCodeForTokenStrategy( this.environmentService, {}, - isGmailSendEmailScopeEnabled, ); setRequestExtraParams(request, { diff --git a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts index 470c0ddf0..3a52e0037 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/guards/google-apis-oauth-request-code.guard.ts @@ -9,7 +9,6 @@ import { GoogleAPIsOauthRequestCodeStrategy } from 'src/engine/core-modules/auth import { TransientTokenService } from 'src/engine/core-modules/auth/token/services/transient-token.service'; import { setRequestExtraParams } from 'src/engine/core-modules/auth/utils/google-apis-set-request-extra-params.util'; import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; -import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service'; @Injectable() @@ -31,11 +30,6 @@ export class GoogleAPIsOauthRequestCodeGuard extends AuthGuard('google-apis') { await this.transientTokenService.verifyTransientToken( request.query.transientToken, ); - const isGmailSendEmailScopeEnabled = - await this.featureFlagService.isFeatureEnabled( - FeatureFlagKey.IsGmailSendEmailScopeEnabled, - workspaceId, - ); setRequestExtraParams(request, { transientToken: request.query.transientToken, @@ -57,11 +51,7 @@ export class GoogleAPIsOauthRequestCodeGuard extends AuthGuard('google-apis') { ); } - new GoogleAPIsOauthRequestCodeStrategy( - this.environmentService, - {}, - isGmailSendEmailScopeEnabled, - ); + new GoogleAPIsOauthRequestCodeStrategy(this.environmentService, {}); const activate = (await super.canActivate(context)) as boolean; diff --git a/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts b/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts index ad60b010d..2512918f7 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/services/google-apis.service.ts @@ -5,8 +5,6 @@ import { v4 } from 'uuid'; import { getGoogleApisOauthScopes } from 'src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes'; import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; -import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; -import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service'; import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator'; import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants'; import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service'; @@ -47,7 +45,6 @@ export class GoogleAPIsService { private readonly calendarQueueService: MessageQueueService, private readonly environmentService: EnvironmentService, private readonly accountsToReconnectService: AccountsToReconnectService, - private readonly featureFlagService: FeatureFlagService, ) {} async refreshGoogleRefreshToken(input: { @@ -99,12 +96,7 @@ export class GoogleAPIsService { const workspaceDataSource = await this.twentyORMGlobalManager.getDataSourceForWorkspace(workspaceId); - const isGmailSendEmailScopeEnabled = - await this.featureFlagService.isFeatureEnabled( - FeatureFlagKey.IsGmailSendEmailScopeEnabled, - workspaceId, - ); - const scopes = getGoogleApisOauthScopes(isGmailSendEmailScopeEnabled); + const scopes = getGoogleApisOauthScopes(); await workspaceDataSource.transaction(async (manager: EntityManager) => { if (!existingAccountId) { diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts index addf4b6e7..741a05ef6 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-common.auth.strategy.ts @@ -19,9 +19,8 @@ export class GoogleAPIsOauthCommonStrategy extends PassportStrategy( constructor( environmentService: EnvironmentService, scopeConfig: GoogleAPIScopeConfig, - isGmailSendEmailScopeEnabled = false, ) { - const scopes = getGoogleApisOauthScopes(isGmailSendEmailScopeEnabled); + const scopes = getGoogleApisOauthScopes(); super({ clientID: environmentService.get('AUTH_GOOGLE_CLIENT_ID'), diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts index c8559bd14..244b1066d 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-exchange-code-for-token.auth.strategy.ts @@ -15,9 +15,8 @@ export class GoogleAPIsOauthExchangeCodeForTokenStrategy extends GoogleAPIsOauth constructor( environmentService: EnvironmentService, scopeConfig: GoogleAPIScopeConfig, - isGmailSendEmailScopeEnabled = false, ) { - super(environmentService, scopeConfig, isGmailSendEmailScopeEnabled); + super(environmentService, scopeConfig); } async validate( diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts index ee0782b9c..6ce3c33c5 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/google-apis-oauth-request-code.auth.strategy.ts @@ -13,9 +13,8 @@ export class GoogleAPIsOauthRequestCodeStrategy extends GoogleAPIsOauthCommonStr constructor( environmentService: EnvironmentService, scopeConfig: GoogleAPIScopeConfig, - isGmailSendEmailScopeEnabled = false, ) { - super(environmentService, scopeConfig, isGmailSendEmailScopeEnabled); + super(environmentService, scopeConfig); } authenticate(req: any, options: any) { diff --git a/packages/twenty-server/src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes.ts b/packages/twenty-server/src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes.ts index e532c3cdf..aa94f12cf 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/utils/get-google-apis-oauth-scopes.ts @@ -1,17 +1,10 @@ -export const getGoogleApisOauthScopes = ( - isGmailSendEmailScopeEnabled = false, -) => { - const scopes = [ +export const getGoogleApisOauthScopes = () => { + return [ 'email', 'profile', 'https://www.googleapis.com/auth/gmail.readonly', 'https://www.googleapis.com/auth/calendar.events', 'https://www.googleapis.com/auth/profile.emails.read', + 'https://www.googleapis.com/auth/gmail.send', ]; - - if (isGmailSendEmailScopeEnabled) { - scopes.push('https://www.googleapis.com/auth/gmail.send'); - } - - return scopes; }; diff --git a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts index 41cf38df9..00ab59655 100644 --- a/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts +++ b/packages/twenty-server/src/engine/core-modules/feature-flag/enums/feature-flag-key.enum.ts @@ -7,7 +7,6 @@ export enum FeatureFlagKey { IsFreeAccessEnabled = 'IS_FREE_ACCESS_ENABLED', IsFunctionSettingsEnabled = 'IS_FUNCTION_SETTINGS_ENABLED', IsWorkflowEnabled = 'IS_WORKFLOW_ENABLED', - IsGmailSendEmailScopeEnabled = 'IS_GMAIL_SEND_EMAIL_SCOPE_ENABLED', IsAnalyticsV2Enabled = 'IS_ANALYTICS_V2_ENABLED', IsUniqueIndexesEnabled = 'IS_UNIQUE_INDEXES_ENABLED', IsMicrosoftSyncEnabled = 'IS_MICROSOFT_SYNC_ENABLED',