Hold on Subscriptions

This commit is contained in:
Jonathan Bourdon
2024-08-03 22:56:12 -04:00
parent 2b30e1a03c
commit 0340904847
7 changed files with 103 additions and 9 deletions

View File

@@ -0,0 +1,31 @@
using FastEndpoints;
using Hutopy.Web.Common;
using Hutopy.Web.Features.Contents.Data;
using Microsoft.EntityFrameworkCore;
namespace Hutopy.Web.Features.Contents.Handlers;
public class GetSubscriptionsHandler(
ContentDbContext context)
: EndpointWithoutRequest
{
public override void Configure()
{
Get("/api/subscriptions");
Options((o => o.WithTags("Creators")));
}
public override async Task HandleAsync(
CancellationToken ct)
{
var userId = HttpContext.User.GetUserId();
await context
.Subscriptions
.Where(s => s.CreatedBy == userId)
.Include(s => s.Creator)
.ToListAsync(cancellationToken: ct);
await SendOkAsync(ct);
}
}