From 2fe32d6c98433e6e4415ef3ce7bdc88bb41f7e30 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 29 Jul 2024 23:24:54 +0800 Subject: [PATCH] :bug: Fix visibility query issue --- pkg/internal/services/posts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index bb004f0..f0795f6 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -19,8 +19,8 @@ func FilterPostWithUserContext(tx *gorm.DB, user *models.Account) *gorm.DB { } tx = tx.Where("visibility != ?", models.PostVisibilityFriends) // TODO Blocked by dealer, need support get friend list - tx = tx.Where("visibility = ? AND ? = ANY (visible_users::jsonb[])", models.PostVisibilitySelected, user.ID) - tx = tx.Where("visibility = ? AND NOT ( ? = ANY (invisible_users::jsonb[]) )", models.PostVisibilitySelected, user.ID) + tx = tx.Where("visibility = ? AND visible_users @> '[?]'", models.PostVisibilitySelected, user.ID) + tx = tx.Where("visibility = ? AND NOT invisible_users @> '[?]'", models.PostVisibilitySelected, user.ID) tx = tx.Where("visibility != ?", models.PostVisibilityNone) return tx