diff --git a/DysonNetwork.Sphere/Chat/ChatController.cs b/DysonNetwork.Sphere/Chat/ChatController.cs index 996b74a..f61e233 100644 --- a/DysonNetwork.Sphere/Chat/ChatController.cs +++ b/DysonNetwork.Sphere/Chat/ChatController.cs @@ -68,6 +68,20 @@ public partial class ChatController( return Ok(result); } + [HttpGet("unread")] + [Authorize] + public async Task> GetTotalUnreadCount() + { + if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized(); + + var accountId = Guid.Parse(currentUser.Id); + var unreadMessages = await cs.CountUnreadMessageForUser(accountId); + + var totalUnreadCount = unreadMessages.Values.Sum(); + + return Ok(totalUnreadCount); + } + public class SendMessageRequest { [MaxLength(4096)] public string? Content { get; set; } @@ -575,4 +589,4 @@ public partial class ChatController( var result = await aus.GetAutocompletion(request.Content, chatId: roomId, limit: 10); return Ok(result); } -} \ No newline at end of file +}