Adds subscriptions

This commit is contained in:
Jonathan Bourdon
2024-08-04 03:27:21 -04:00
parent 303619cc18
commit 68ef947e26
12 changed files with 413 additions and 147 deletions

View File

@@ -1,13 +1,14 @@
using FastEndpoints;
using Hutopy.Web.Common;
using Hutopy.Web.Features.Contents.Data;
using Hutopy.Web.Features.Contents.Handlers.Models;
using Microsoft.EntityFrameworkCore;
namespace Hutopy.Web.Features.Contents.Handlers;
public class GetSubscriptionsHandler(
ContentDbContext context)
: EndpointWithoutRequest
: EndpointWithoutRequest<List<SubscriptionModel>>
{
public override void Configure()
{
@@ -20,12 +21,15 @@ public class GetSubscriptionsHandler(
{
var userId = HttpContext.User.GetUserId();
await context
var subscriptions = await context
.Subscriptions
.Where(s => s.CreatedBy == userId)
.Include(s => s.Creator)
.Select(s => new SubscriptionModel(
s.CreatorId,
s.Creator!.Name,
s.Creator.StoredDataUrls.ProfilePictureUrl))
.ToListAsync(cancellationToken: ct);
await SendOkAsync(ct);
await SendOkAsync(subscriptions, ct);
}
}