Adds Messaging streaming

This commit is contained in:
Jonathan Bourdon
2024-07-19 00:44:03 -04:00
parent 8b5ab2d769
commit d268625f19
9 changed files with 80 additions and 58 deletions

View File

@@ -7,7 +7,7 @@ namespace Hutopy.Web.Features.Contents.Handlers;
public sealed class GetContentsByUserRequest
{
public Guid UserId { get; set; }
[BindFrom("max_items")] public int MaxItems { get; set; } = 10;
[BindFrom("page_size")] public int PageSize { get; set; } = 10;
[BindFrom("last_id")] public Guid? LastId { get; set; }
}
@@ -30,12 +30,12 @@ public class GetContentsByUser(
.Contents
.Where(c => c.CreatedBy == req.UserId);
if (req.LastId is not null)
query = query.OrderByDescending(c => c.Id).Where(c => c.Id < req.LastId.Value);
else
query = query.OrderByDescending(c => c.Id);
query = query.OrderByDescending(c => c.CreatedAt);
query = query.Take(req.MaxItems);
if (req.LastId is not null)
query = query.Where(c => c.Id < req.LastId.Value);
query = query.Take(req.PageSize);
var posts = await query.ToListAsync(cancellationToken: ct);