File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -570,12 +570,27 @@ export class WebhookService {
570570 async checkForNotificationsToDeliver ( ) {
571571 const now = new Date ( )
572572 const fiveMinutesAgo = new Date ( now . getTime ( ) - 5 * 60 * 1000 )
573+ const oneMonthAgo = new Date ( now . getTime ( ) - 30 * 24 * 60 * 60 * 1000 )
574+
575+ // Mark notifications older than one month as aborted so they are no longer retried
576+ await this . webhookNotificationModel . updateMany (
577+ {
578+ nextDeliveryAttemptAt : { $lte : fiveMinutesAgo } ,
579+ deliveredAt : null ,
580+ deliveryAttemptCount : { $lt : 10 } ,
581+ deliveryAttemptAbortedAt : null ,
582+ createdAt : { $lt : oneMonthAgo } ,
583+ } ,
584+ { $set : { deliveryAttemptAbortedAt : now } } ,
585+ )
586+
573587 const notifications = await this . webhookNotificationModel
574588 . find ( {
575589 nextDeliveryAttemptAt : { $lte : fiveMinutesAgo } ,
576590 deliveredAt : null ,
577591 deliveryAttemptCount : { $lt : 10 } ,
578592 deliveryAttemptAbortedAt : null ,
593+ createdAt : { $gte : oneMonthAgo } ,
579594 } )
580595 . sort ( { nextDeliveryAttemptAt : 1 } )
581596 . limit ( 200 )
You can’t perform that action at this time.
0 commit comments