feat(messaging): skip webhook-active channels in list-fetch crons until sync is stale (#22183)

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/22183?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
neo773
2026-06-25 20:31:17 +05:30
committed by GitHub
parent f270fb25c8
commit 24c042f0ef
5 changed files with 72 additions and 3 deletions
@@ -7,6 +7,7 @@ import { In, Not, Repository } from 'typeorm';
import {
MessageChannelSyncStage,
MessageChannelType,
WebhookSubscriptionStatus,
} from 'twenty-shared/types';
import { SentryCronMonitor } from 'src/engine/core-modules/cron/sentry-cron-monitor.decorator';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
@@ -20,6 +21,7 @@ import {
MessagingMessageListFetchJob,
type MessagingMessageListFetchJobData,
} from 'src/modules/messaging/message-import-manager/jobs/messaging-message-list-fetch.job';
import { isLastSuccessfulSyncStale } from 'src/modules/connected-account/utils/is-last-successful-sync-stale.util';
import { isThrottled } from 'src/modules/connected-account/utils/is-throttled';
import { MessageChannelEntity } from 'src/engine/metadata-modules/message-channel/entities/message-channel.entity';
import { toIsoStringOrNull } from 'src/utils/date/toIsoStringOrNull';
@@ -71,7 +73,12 @@ export class MessagingMessageListFetchCronJob {
toIsoStringOrNull(messageChannel.syncStageStartedAt),
messageChannel.throttleFailureCount,
toIsoStringOrNull(messageChannel.throttleRetryAfter),
),
) &&
(messageChannel.webhookSubscriptionStatus !==
WebhookSubscriptionStatus.ACTIVE ||
isLastSuccessfulSyncStale(
toIsoStringOrNull(messageChannel.syncedAt),
)),
);
const throttledCount =