Adds subscriptions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user