technical edits

This commit is contained in:
Artemy
2025-12-12 17:23:01 +07:00
parent bf2aca40d3
commit 7e6f914878
23 changed files with 461 additions and 114 deletions
@@ -11,20 +11,17 @@ namespace Govor.Application.Services.Authentication;
public class AuthService : IAccountService
{
private readonly IPasswordHasher _passwordHasher;
private readonly IJwtService _jwtService;
private readonly IUsersRepository _usersRepository;
private readonly IAdminsRepository _adminsRepository;
private readonly IUsernameValidator _usernameValidator;
public AuthService(IUsersRepository usersRepository,
IJwtService jwtService,
IPasswordHasher passwordHasher,
IAdminsRepository adminsRepository,
IUsernameValidator usernameValidator
)
{
_usersRepository = usersRepository;
_jwtService = jwtService;
_passwordHasher = passwordHasher;
_adminsRepository = adminsRepository;
_usernameValidator = usernameValidator;
@@ -27,9 +27,7 @@ public class FriendshipService : IFriendshipService
{
all = await _usersRepository.SearchPotentialFriendsAsync(currentId, query);
return all
.Where(u => u.Id != currentId)
.ToList();
return all;
}
catch (NotFoundByKeyException<(string, Guid)> ex)
{
@@ -37,7 +35,7 @@ public class FriendshipService : IFriendshipService
}
catch (NotFoundByKeyException<Guid> ex)
{
return all.Where(u => u.Id != currentId).ToList();
return [];
}
catch (Exception ex)
{
@@ -58,7 +56,7 @@ public class FriendshipService : IFriendshipService
}
catch (NotFoundByKeyException<Guid> ex)
{
throw new InvalidOperationException("User not found", ex);
throw new InvalidOperationException("Nothing was found for the specified id.", ex);
}
}
}
@@ -49,11 +49,5 @@ public class InvitesService : IInvitesService
throw new InviteLinkInvalidException(inviteCode);
}
}
public string GenerateInvitationLink(Invitation invitation)
{
throw new NotImplementedException();
}
}
+17 -8
View File
@@ -1,6 +1,7 @@
using Govor.Application.Interfaces;
using Govor.Application.Profiles;
using Govor.Core.Repositories.Users;
using Govor.Data.Repositories.Exceptions;
using Microsoft.Extensions.Logging;
namespace Govor.Application.Services;
@@ -19,15 +20,23 @@ public class ProfileService : IProfileService
public async Task<UserProfile> GetUserProfileAsync(Guid userId)
{
_logger.LogInformation("Gettings user {userId} profile", userId);
var user = await _userRepository.FindByIdAsync(userId);
return new UserProfile
try
{
Id = user.Id,
Username = user.Username,
Description = user.Description,
IconId = user.IconId
};
var user = await _userRepository.FindByIdAsync(userId);
return new UserProfile
{
Id = user.Id,
Username = user.Username,
Description = user.Description,
IconId = user.IconId
};
}
catch (NotFoundByKeyException<Guid> ex)
{
throw new NotFoundException("User's profile cant be found with given id", ex);
}
}
public async Task SetDescription(string description, Guid userId)