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> { 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); } }