Fix some update / upload stuff with images. Added more info to minimalUser

This commit is contained in:
Dominic Villemure
2024-07-05 00:13:26 -04:00
parent 93b3f2053a
commit cb55989c71
6 changed files with 41 additions and 6 deletions

View File

@@ -3,15 +3,25 @@ using Hutopy.Application.Common.Interfaces;
namespace Hutopy.Application.Users.Commands;
/// <summary>
/// Upload a profile picture. If the user has the url already, set the ProfilePictureUrl in the user only without upload.
/// </summary>
public class UploadProfilePictureCommand : IRequest<string>
{
public required Stream ProfilePicture { get; init; }
public string ProfilePictureUrl { get; init; } = string.Empty;
}
public class UploadProfilePictureCommandHandler(IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler<UploadProfilePictureCommand, string>
{
public async Task<string> Handle(UploadProfilePictureCommand request, CancellationToken cancellationToken)
{
if (!string.IsNullOrEmpty(request.ProfilePictureUrl))
{
await identityService.UpdateCurrentUserProfilePictureUrlAsync(request.ProfilePictureUrl);
return request.ProfilePictureUrl;
}
var identityUser = await identityService.GetCurrentUserAsync();
var currentUserId = new Guid(identityUser?.Id ?? "").ToString();