mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Refactor user ID access in SignalR hubs and add online user tracking
Introduces IHubUserAccessor and its implementation to centralize user ID retrieval from SignalR HubCallerContext, replacing duplicated logic in ChatsHub, FriendsHub, and PresenceHub. Moves extension and mapping files to a Common directory, adds UserToUserDtoMappingAction for online status mapping, and implements OnlineUserStore with tests for tracking online users. Updates dependency injection and test code to use the new abstractions.
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Govor.Application.Interfaces.UserOnlineStatus;
|
||||
|
||||
namespace Govor.Application.Services.UserOnlineStatus;
|
||||
|
||||
public class OnlineUserStore : IOnlineUserStore
|
||||
{
|
||||
private readonly ConcurrentDictionary<Guid, DateTime> _onlineUsers = new();
|
||||
|
||||
public void SetOnlineUser(Guid userId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_onlineUsers[userId] = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public void SetOfflineUser(Guid userId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_onlineUsers.TryRemove(userId, out _);
|
||||
}
|
||||
|
||||
public bool IsOnline(Guid userId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return _onlineUsers.ContainsKey(userId);
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<Guid> GetAllOnlineUsers()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return _onlineUsers.Keys.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user