From 79a61cc732fb6b92a78a9387ad9082ac43ee2b86 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 11 Dec 2024 23:05:31 +0800 Subject: [PATCH] :bug: Fix posts filter with user context filtered all the posts --- pkg/internal/services/posts.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index 64c4d78..05d10d3 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -132,7 +132,9 @@ func FilterPostWithUserContext(tx *gorm.DB, user *authm.Account) *gorm.DB { datatypes.JSONQuery("invisible_users").HasKey(strconv.Itoa(int(user.ID))), ) - tx = tx.Where("publisher_id NOT IN ?", invisibleList) + if len(invisibleList) > 0 { + tx = tx.Where("publisher_id NOT IN ?", invisibleList) + } return tx }