Fix Enumerable usage in CommentController

This commit is contained in:
Slendy 2023-02-11 19:08:03 -06:00
parent 96c34c83a7
commit 75a5e70635
No known key found for this signature in database
GPG key ID: 7288D68361B91428

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Administration;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Levels;
@ -76,12 +77,11 @@ public class CommentController : ControllerBase
where blockedProfile.UserId == token.UserId
select blockedProfile.BlockedUserId).ToListAsync();
List<Comment> comments = await this.database.Comments.Include(c => c.Poster)
List<Comment> comments = await this.database.Comments.Where(p => p.TargetId == targetId && p.Type == type)
.OrderByDescending(p => p.Timestamp)
.Where(p => p.TargetId == targetId && p.Type == type)
.ToAsyncEnumerable()
.Where(p => !p.Poster.IsBanned)
.Where(p => !blockedUsers.Contains(p.PosterUserId))
.Include(c => c.Poster)
.Where(p => p.Poster.PermissionLevel != PermissionLevel.Banned)
.Skip(Math.Max(0, pageStart - 1))
.Take(Math.Min(pageSize, 30))
.ToListAsync();