+ Tips
+ Memberships - DDD - FutureCreator - UserTransactions
This commit is contained in:
34
src/Web/Features/Contents/Handlers/GetFollowedCreators.cs
Normal file
34
src/Web/Features/Contents/Handlers/GetFollowedCreators.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Contents.Handlers.Models;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
[PublicAPI]
|
||||
public class GetFollowedCreatorsHandler(
|
||||
ContentDbContext context)
|
||||
: EndpointWithoutRequest<List<FollowModel>>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/creators/followed");
|
||||
Options((o => o.WithTags("Creators")));
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
CancellationToken ct)
|
||||
{
|
||||
var userId = HttpContext.User.GetUserId();
|
||||
|
||||
var subscriptions = await context
|
||||
.Followers
|
||||
.Where(s => s.CreatedBy == userId)
|
||||
.Select(s => new FollowModel(
|
||||
s.CreatorId,
|
||||
s.Creator!.Name,
|
||||
s.Creator.Images.Logo))
|
||||
.ToListAsync(cancellationToken: ct);
|
||||
|
||||
await SendOkAsync(subscriptions, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user