using Knot.Shared.Kernel; namespace Knot.Modules.Auth.Infrastructure.Services; public sealed class UserDisplayNameProvider : IUserDisplayNameProvider { private readonly IUserRepository _userRepository; public UserDisplayNameProvider(IUserRepository userRepository) { _userRepository = userRepository; } public async Task GetDisplayNameAsync(Guid userId, CancellationToken ct = default) { var user = await _userRepository.GetByIdAsync(userId, ct); return user?.DisplayName ?? "User"; } public async Task GetUserInfoAsync(Guid userId, CancellationToken ct = default) { var user = await _userRepository.GetByIdAsync(userId, ct); if (user == null) { return null; } return new UserInfo(user.Id, user.Username, user.DisplayName, user.Avatar); } public async Task> GetUsersInfoAsync(IEnumerable userIds, CancellationToken ct = default) { var users = await _userRepository.GetByIdsAsync(userIds, ct); var result = new System.Collections.Generic.Dictionary(); foreach (var user in users) { result[user.Id] = new UserInfo(user.Id, user.Username, user.DisplayName, user.Avatar); } return result; } }