Support notification controller get content without marking as read

This commit is contained in:
2026-01-04 00:21:25 +08:00
parent 6fd77c5c31
commit 6b592156c9

View File

@@ -36,7 +36,8 @@ public class NotificationController(
[FromQuery] int offset = 0, [FromQuery] int offset = 0,
// The page size set to 5 is to avoid the client pulled the notification // The page size set to 5 is to avoid the client pulled the notification
// but didn't render it in the screen-viewable region. // but didn't render it in the screen-viewable region.
[FromQuery] int take = 8 [FromQuery] int take = 8,
[FromQuery] bool unmark = false
) )
{ {
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
@@ -54,7 +55,8 @@ public class NotificationController(
.ToListAsync(); .ToListAsync();
Response.Headers["X-Total"] = totalCount.ToString(); Response.Headers["X-Total"] = totalCount.ToString();
await nty.MarkNotificationsViewed(notifications.ToList());
if (!unmark) await nty.MarkNotificationsViewed(notifications.ToList());
return Ok(notifications); return Ok(notifications);
} }