mirror of
https://github.com/vernu/textbee.git
synced 2026-05-19 05:46:23 -04:00
Merge pull request #195 from vernu/dev
skip automatic disabling of webhook subscriptions if theres a recent successful delivery
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user