using PnvPanel.Application.Common.Interfaces; using PnvPanel.Application.Common.Messaging; using PnvPanel.Application.Common.Models; namespace PnvPanel.Application.Auth.Me; public sealed class GetCurrentUserQueryHandler(IIdentityService identityService, ICurrentUser currentUser) : IQueryHandler> { public async Task> Handle(GetCurrentUserQuery query, CancellationToken cancellationToken) { if (currentUser.UserId is not { } userId) return Result.Failure(AuthErrors.Unauthorized); var profile = await identityService.GetProfileAsync(userId, cancellationToken); if (profile is null) return Result.Failure(AuthErrors.Unauthorized); var telegramInfo = await identityService.GetTelegramLinkInfoAsync(userId, cancellationToken); return Result.Success(new CurrentUserDto(profile.Id, profile.UserName, profile.Role, profile.IsActivated, telegramInfo.IsLinked)); } }