From 27b6f2022f32efca3d4b74b2f7d18035f1aae36e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 1 Aug 2025 17:13:13 +0800 Subject: [PATCH] :sparkles: Filter post with type --- DysonNetwork.Sphere/Post/PostController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DysonNetwork.Sphere/Post/PostController.cs b/DysonNetwork.Sphere/Post/PostController.cs index 23ce2cd..4e4fc72 100644 --- a/DysonNetwork.Sphere/Post/PostController.cs +++ b/DysonNetwork.Sphere/Post/PostController.cs @@ -26,7 +26,8 @@ public class PostController( public async Task>> ListPosts( [FromQuery] int offset = 0, [FromQuery] int take = 20, - [FromQuery(Name = "pub")] string? pubName = null + [FromQuery(Name = "pub")] string? pubName = null, + [FromQuery(Name = "type")] int? type = null ) { HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue); @@ -47,6 +48,8 @@ public class PostController( var query = db.Posts.AsQueryable(); if (publisher != null) query = query.Where(p => p.Publisher.Id == publisher.Id); + if (type != null) + query = query.Where(p => p.Type == (PostType)type); query = query .FilterWithVisibility(currentUser, userFriends, userPublishers, isListing: true);