From f547da4ee90920923df2dffb0b475ebafb856c90 Mon Sep 17 00:00:00 2001 From: neo773 <62795688+neo773@users.noreply.github.com> Date: Fri, 10 Jul 2026 15:03:53 +0530 Subject: [PATCH] Gate connected-account webhook subscriptions behind config (#22761) Now gated behind IS_CONNECTED_ACCOUNT_WEBHOOK_SUBSCRIPTION_ENABLED (default false). Merge + deploy twentyhq/twenty-infra#780 first. Review in cubic Co-authored-by: Charles Bochet --- .../twenty-config/config-variables.ts | 10 ++++++++++ .../services/channel-sync.service.ts | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts b/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts index f8430e9d8a..6be4604e08 100644 --- a/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts +++ b/packages/twenty-server/src/engine/core-modules/twenty-config/config-variables.ts @@ -209,6 +209,16 @@ export class ConfigVariables { @IsOptional() MESSAGING_GMAIL_PUBSUB_VERIFICATION_EMAIL: string; + @ConfigVariablesMetadata({ + group: ConfigVariablesGroup.ADVANCED_SETTINGS, + description: + 'Enable webhook-based sync for connected accounts (provider push ' + + 'notifications on top of polling). Requires publicly reachable ' + + 'webhook endpoints.', + type: ConfigVariableType.BOOLEAN, + }) + IS_CONNECTED_ACCOUNT_WEBHOOK_SUBSCRIPTION_ENABLED = false; + @ConfigVariablesMetadata({ group: ConfigVariablesGroup.ADVANCED_SETTINGS, description: 'Enable or disable the IMAP messaging integration', diff --git a/packages/twenty-server/src/modules/connected-account/channel-sync/services/channel-sync.service.ts b/packages/twenty-server/src/modules/connected-account/channel-sync/services/channel-sync.service.ts index 8ce21351a5..d76251376f 100644 --- a/packages/twenty-server/src/modules/connected-account/channel-sync/services/channel-sync.service.ts +++ b/packages/twenty-server/src/modules/connected-account/channel-sync/services/channel-sync.service.ts @@ -13,6 +13,7 @@ import { Not, Repository } from 'typeorm'; 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'; +import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service'; import { CalendarChannelEntity } from 'src/engine/metadata-modules/calendar-channel/entities/calendar-channel.entity'; import { MessageChannelEntity } from 'src/engine/metadata-modules/message-channel/entities/message-channel.entity'; import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager'; @@ -53,6 +54,7 @@ export class ChannelSyncService { private readonly messageChannelSyncStatusService: MessageChannelSyncStatusService, @InjectRepository(CalendarChannelEntity) private readonly calendarChannelRepository: Repository, + private readonly twentyConfigService: TwentyConfigService, ) {} async startChannelSync(input: StartChannelSyncInput): Promise { @@ -92,6 +94,14 @@ export class ChannelSyncService { }, ); + if ( + !this.twentyConfigService.get( + 'IS_CONNECTED_ACCOUNT_WEBHOOK_SUBSCRIPTION_ENABLED', + ) + ) { + continue; + } + try { await this.webhookQueueService.add( CreateWebhookSubscriptionJob.name, @@ -144,6 +154,14 @@ export class ChannelSyncService { }, ); + if ( + !this.twentyConfigService.get( + 'IS_CONNECTED_ACCOUNT_WEBHOOK_SUBSCRIPTION_ENABLED', + ) + ) { + continue; + } + try { await this.webhookQueueService.add( CreateWebhookSubscriptionJob.name,