Skip to content

The open alternative to Salesforce, designed for AI.

Gate connected-account webhook subscriptions behind config (#22761)

neo773f547da4ee909
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 f8430e9d8a6..6be4604e087 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 8ce21351a53..d76251376ff 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<CalendarChannelEntity>,
+ private readonly twentyConfigService: TwentyConfigService,
) {}
async startChannelSync(input: StartChannelSyncInput): Promise<void> {
@@ -92,6 +94,14 @@ export class ChannelSyncService {
},
);
+ if (
+ !this.twentyConfigService.get(
+ 'IS_CONNECTED_ACCOUNT_WEBHOOK_SUBSCRIPTION_ENABLED',
+ )
+ ) {
+ continue;
+ }
+
try {
await this.webhookQueueService.add<CreateWebhookSubscriptionJobData>(
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<CreateWebhookSubscriptionJobData>(
CreateWebhookSubscriptionJob.name,