mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
be0edb0f94
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.
21 lines
599 B
C#
21 lines
599 B
C#
using AutoMapper;
|
|
using Govor.Application.Interfaces.UserOnlineStatus;
|
|
using Govor.Contracts.DTOs;
|
|
using Govor.Core.Models.Users;
|
|
|
|
namespace Govor.API.Extensions.Mapping;
|
|
|
|
public class UserToUserDtoMappingAction : IMappingAction<User, UserDto>
|
|
{
|
|
private readonly IOnlineUserStore _onlineUserStore;
|
|
|
|
public UserToUserDtoMappingAction(IOnlineUserStore onlineUserStore)
|
|
{
|
|
_onlineUserStore = onlineUserStore;
|
|
}
|
|
|
|
public void Process(User source, UserDto destination, ResolutionContext context)
|
|
{
|
|
destination.IsOnline = _onlineUserStore.IsOnline(source.Id);
|
|
}
|
|
} |