From 7c797ff0c9ccc5ff8306703167a87830c2b73061 Mon Sep 17 00:00:00 2001 From: neo773 <62795688+neo773@users.noreply.github.com> Date: Mon, 3 Aug 2026 15:13:54 +0530 Subject: [PATCH] Filter connected account webhook renewal to exclude accounts with failed authentication errors (#23694) /closes TWENTY-SERVER-J1F Review in cubic Co-authored-by: neo773 --- .../jobs/webhook-subscription-renewal.cron.job.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/modules/connected-account/webhook-subscription-manager/crons/jobs/webhook-subscription-renewal.cron.job.ts b/packages/twenty-server/src/modules/connected-account/webhook-subscription-manager/crons/jobs/webhook-subscription-renewal.cron.job.ts index e2ab20205c..f95b0865ea 100644 --- a/packages/twenty-server/src/modules/connected-account/webhook-subscription-manager/crons/jobs/webhook-subscription-renewal.cron.job.ts +++ b/packages/twenty-server/src/modules/connected-account/webhook-subscription-manager/crons/jobs/webhook-subscription-renewal.cron.job.ts @@ -6,7 +6,13 @@ import { WebhookSubscriptionStatus, } from 'twenty-shared/types'; import { WorkspaceActivationStatus } from 'twenty-shared/workspace'; -import { type FindManyOptions, In, LessThanOrEqual, Repository } from 'typeorm'; +import { + type FindManyOptions, + In, + IsNull, + LessThanOrEqual, + Repository, +} from 'typeorm'; import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator'; import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator'; @@ -94,7 +100,10 @@ export class WebhookSubscriptionRenewalCronJob { repository: Repository, activeWorkspaceIds: string[], ): Promise { - const workspaceScope = { workspaceId: In(activeWorkspaceIds) }; + const workspaceScope = { + workspaceId: In(activeWorkspaceIds), + connectedAccount: { authFailedAt: IsNull() }, + }; const renewalThreshold = new Date( Date.now() + WEBHOOK_SUBSCRIPTION_RENEWAL_BUFFER_MS, );