Merge pull request #195 from vernu/dev

skip automatic disabling of webhook subscriptions if theres a recent successful delivery
This commit is contained in:
Israel Abebe
2026-03-06 13:59:07 +03:00
committed by GitHub

View File

@@ -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 }