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 banner picture. If the user has the url already, set the BannerPictureUrl in the user only without upload.
/// </summary>
public class UploadBannerPictureCommand : IRequest<string>
{
public required Stream BannerPicture { get; init; }
public string BannerPictureUrl { get; init; } = string.Empty;
}
public class UploadBannerPictureCommandHandler(IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler<UploadBannerPictureCommand, string>
{
public async Task<string> Handle(UploadBannerPictureCommand request, CancellationToken cancellationToken)
{
if (!string.IsNullOrEmpty(request.BannerPictureUrl))
{
await identityService.UpdateCurrentUserBannerPictureUrlAsync(request.BannerPictureUrl);
return request.BannerPictureUrl;
}
var identityUser = await identityService.GetCurrentUserAsync();
var currentUserId = new Guid(identityUser?.Id ?? "").ToString();

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();

View File

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

View File

@@ -31,9 +31,11 @@ public class GetMinimalUserQueryHandler(
var user = new MinimalUserDto
{
Id = identityUser?.Id ?? string.Empty,
FirstName = identityUser?.FirstName ?? string.Empty,
LastName = identityUser?.LastName ?? string.Empty,
UserName = identityUser?.UserName ?? string.Empty,
Occupation = identityUser?.Occupation ?? string.Empty,
SocialNetworks = identityUser?.SocialNetworks ?? new(),
ProfileColors = identityUser?.ProfileColors ?? new(),
StoredDataUrls = identityUser?.StoredDataUrls ?? new(),

View File

@@ -4,9 +4,11 @@ namespace Hutopy.Application.Users.Queries.GetMinimalUser;
public class MinimalUserDto
{
public required string Id { get; init; }
public required string FirstName { get; init; }
public required string LastName { get; init; }
public required string UserName { get; init; } = String.Empty;
public required string Occupation { get; init; } = String.Empty;
public SocialNetworksModel SocialNetworks { get; init; } = new();
public ProfileColorsModel ProfileColors { get; init; } = new();