mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-22 20:24: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,4 +1,5 @@
|
||||
using AutoFixture;
|
||||
using Govor.API.Common.SignalR.Helpers;
|
||||
using Govor.API.Hubs;
|
||||
using Govor.Application.Interfaces;
|
||||
using Govor.Application.Interfaces.Messages;
|
||||
@@ -13,6 +14,7 @@ public class ChatsHubTests
|
||||
private Mock<ILogger<ChatsHub>> _loggerMock;
|
||||
private Mock<IMessageCommandService> _messageServiceMock;
|
||||
private Mock<IUserGroupsService> _userGroupsServiceMock;
|
||||
private Mock<IHubUserAccessor> _hubUserAccessorMock;
|
||||
private Fixture _fixture;
|
||||
private ChatsHub _chatsHub;
|
||||
|
||||
@@ -26,11 +28,13 @@ public class ChatsHubTests
|
||||
_messageServiceMock = new Mock<IMessageCommandService>();
|
||||
_userGroupsServiceMock = new Mock<IUserGroupsService>();
|
||||
_loggerMock = new Mock<ILogger<ChatsHub>>();
|
||||
_hubUserAccessorMock = new Mock<IHubUserAccessor>();
|
||||
|
||||
_chatsHub = new ChatsHub(
|
||||
_loggerMock.Object,
|
||||
_messageServiceMock.Object,
|
||||
_userGroupsServiceMock.Object
|
||||
_userGroupsServiceMock.Object,
|
||||
_hubUserAccessorMock.Object
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user