Unread count notification APIs

This commit is contained in:
2025-05-20 01:51:59 +08:00
parent 793043aba2
commit 61f7764510
2 changed files with 34 additions and 5 deletions

View File

@ -140,6 +140,18 @@ public class NotificationService
await Task.WhenAll(tasks);
}
public async Task MarkNotificationsViewed(ICollection<Notification> notifications)
{
var now = SystemClock.Instance.GetCurrentInstant();
var id = notifications.Where(n => n.ViewedAt == null).Select(n => n.Id).ToList();
if (id.Count == 0) return;
await _db.Notifications
.Where(n => id.Contains(n.Id))
.ExecuteUpdateAsync(s => s.SetProperty(n => n.ViewedAt, now)
);
}
private async Task _PushSingleNotification(Notification notification, NotificationPushSubscription subscription)
{
switch (subscription.Provider)