Adds multiple media urls for content
This commit is contained in:
45
src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs
Normal file
45
src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using FastEndpoints;
|
||||
using FluentValidation;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
public sealed class GetCreatorByAliasRequest
|
||||
{
|
||||
public string CreatorAlias { get; init; }
|
||||
}
|
||||
|
||||
public sealed class GetCreatorByAliasRequestValidator
|
||||
: Validator<GetCreatorByAliasRequest>
|
||||
{
|
||||
public GetCreatorByAliasRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.CreatorAlias)
|
||||
.NotNull().WithMessage("You should specify the CreatorAlias")
|
||||
.NotEmpty().WithMessage("You should specify a valid/not empty CreatorAlias");
|
||||
}
|
||||
}
|
||||
|
||||
public class GetCreatorByAlias(
|
||||
IIdentityService identityService)
|
||||
: Endpoint<GetCreatorByAliasRequest, UserModel?>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Options((o => o.WithTags("Creators")));
|
||||
Get("/api/creators/@{CreatorAlias}");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
GetCreatorByAliasRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var user = await identityService.FindUserByCreatorAliasAsync(
|
||||
req.CreatorAlias,
|
||||
ct);
|
||||
|
||||
await SendAsync(user, cancellation: ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user