fix issues with NotificationJob related to MailKit behavior

This commit is contained in:
sbwalker
2025-09-18 17:19:30 -04:00
parent a6f4921055
commit 1995a96a98
2 changed files with 55 additions and 45 deletions

View File

@ -144,14 +144,14 @@ namespace Oqtane.Repository
// delete notifications in batches of 100 records
var count = 0;
var purgedate = DateTime.UtcNow.AddDays(-age);
var notifications = db.Notification.Where(item => item.SiteId == siteId && item.FromUserId == null && item.IsDelivered && item.DeliveredOn < purgedate)
var notifications = db.Notification.Where(item => item.SiteId == siteId && item.FromUserId == null && (item.IsDeleted || item.IsDelivered && item.DeliveredOn < purgedate))
.OrderBy(item => item.DeliveredOn).Take(100).ToList();
while (notifications.Count > 0)
{
count += notifications.Count;
db.Notification.RemoveRange(notifications);
db.SaveChanges();
notifications = db.Notification.Where(item => item.SiteId == siteId && item.FromUserId == null && item.IsDelivered && item.DeliveredOn < purgedate)
notifications = db.Notification.Where(item => item.SiteId == siteId && item.FromUserId == null && (item.IsDeleted || item.IsDelivered && item.DeliveredOn < purgedate))
.OrderBy(item => item.DeliveredOn).Take(100).ToList();
}
return count;