Hold on Subscriptions
This commit is contained in:
31
src/Web/Features/Contents/Handlers/GetSubscriptions.cs
Normal file
31
src/Web/Features/Contents/Handlers/GetSubscriptions.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user