mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 11:44:56 +00:00
technical edits
This commit is contained in:
@@ -22,4 +22,4 @@ public record Media(Guid UploaderId,
|
||||
MediaOwnerType OwnerType,
|
||||
Guid? OwnerId);
|
||||
|
||||
public record MediaUploadResult(Guid? MediaId, string Url);
|
||||
public record MediaUploadResult(Guid MediaId, string Url);
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user