From b42a6818165512c1cfd59e69115e6c648a436171 Mon Sep 17 00:00:00 2001 From: isra el Date: Fri, 6 Mar 2026 13:42:15 +0300 Subject: [PATCH] chore(api): skip automatic disabling of webhook subscriptions if theres a recent successful delivery --- api/src/webhook/webhook.service.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/src/webhook/webhook.service.ts b/api/src/webhook/webhook.service.ts index 5c69ea8..42ce7bf 100644 --- a/api/src/webhook/webhook.service.ts +++ b/api/src/webhook/webhook.service.ts @@ -639,6 +639,7 @@ export class WebhookService { const { threshold, lookbackDays, minFailureRate } = this.getAutoDisableConfig() const now = new Date() const since = new Date(now.getTime() - lookbackDays * 24 * 60 * 60 * 1000) + const twentyFourHoursAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000) const subscriptionCounts = await this.webhookNotificationModel.aggregate<{ _id: mongoose.Types.ObjectId @@ -738,6 +739,10 @@ export class WebhookService { ) if (!stats) continue + if (subscription?.lastDeliverySuccessAt >= twentyFourHoursAgo) { + continue + } + const { failureCount, successCount, totalAttempts, failureRatePercent } = stats const noteText = `Auto-disabled: ${failureCount} failed and ${successCount} succeeded (${totalAttempts} total) in the last ${lookbackDays} days — failure rate ${failureRatePercent}%. Re-enable in dashboard when your endpoint is ready.` const noteEntry = { at: new Date(), text: noteText }