Transit
This commit is contained in:
@@ -4,10 +4,26 @@ using Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public sealed class GetCreatorProfileResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid CreatedBy { get; set; }
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Verified { get; set; }
|
||||
public bool AcceptDonation { get; set; }
|
||||
public Colors Colors { get; set; }
|
||||
public Images Images { get; set; }
|
||||
public PresentationInfos PresentationInfos { get; set; }
|
||||
public Socials Socials { get; set; }
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public class GetCreatorProfileHandler(
|
||||
ContentDbContext context)
|
||||
: EndpointWithoutRequest<Creator>
|
||||
: EndpointWithoutRequest<GetCreatorProfileResponse>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
@@ -21,9 +37,23 @@ public class GetCreatorProfileHandler(
|
||||
{
|
||||
var creator = await context
|
||||
.Creators
|
||||
.FindAsync(
|
||||
[HttpContext.User.GetUserId()],
|
||||
cancellationToken: ct);
|
||||
.Where(c => c.Id == HttpContext.User.GetUserId())
|
||||
.AsNoTracking()
|
||||
.Select(c => new GetCreatorProfileResponse
|
||||
{
|
||||
Id = c.Id,
|
||||
CreatedBy = c.CreatedBy,
|
||||
CreatedAt = c.CreatedAt,
|
||||
Title = c.Title,
|
||||
Name = c.Slugs.NormalizedName,
|
||||
Verified = c.Verified,
|
||||
AcceptDonation = c.AcceptDonation,
|
||||
Colors = c.Colors,
|
||||
Images = c.Images,
|
||||
PresentationInfos = c.PresentationInfos,
|
||||
Socials = c.Socials,
|
||||
})
|
||||
.SingleOrDefaultAsync(ct);
|
||||
|
||||
if (creator is null) await SendNotFoundAsync(ct);
|
||||
else await SendAsync(creator, cancellation: ct);
|
||||
|
||||
Reference in New Issue
Block a user