🐛 Fix post service grpc call made type filter wrong

This commit is contained in:
2025-11-22 17:55:45 +08:00
parent 590519c28f
commit 27e3cc853a

View File

@@ -3,6 +3,7 @@ using DysonNetwork.Shared.Models;
using Grpc.Core;
using Microsoft.EntityFrameworkCore;
using NodaTime.Serialization.Protobuf;
using PostType = DysonNetwork.Shared.Proto.PostType;
namespace DysonNetwork.Sphere.Post;
@@ -172,7 +173,11 @@ public class PostServiceGrpc(AppDatabase db, PostService ps) : Shared.Proto.Post
if (request.Types_.Count > 0)
{
var types = request.Types_.Select(t => (Shared.Models.PostType)t).Distinct();
var types = request.Types_.Select(t => t switch
{
PostType.Article => Shared.Models.PostType.Article,
_ => Shared.Models.PostType.Moment
}).Distinct();
query = query.Where(p => types.Contains(p.Type));
}