From 2d66b8acc0c45a177336ccf0009ca5bf61f8d9c6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 29 Jul 2024 23:33:55 +0800 Subject: [PATCH] :bug: Fix visibility query type issue --- pkg/internal/services/posts.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index f0795f6..7e73884 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -18,10 +18,16 @@ func FilterPostWithUserContext(tx *gorm.DB, user *models.Account) *gorm.DB { return tx.Where("visibility = ?", models.PostVisibilityAll) } - tx = tx.Where("visibility != ?", models.PostVisibilityFriends) // TODO Blocked by dealer, need support get friend list - 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) + // TODO Blocked by dealer, need support get friend list + tx = tx.Where( + "visibility != ? OR (visibility = ? AND visible_users @> '[?]'::jsonb) OR (visibility = ? AND NOT invisible_users @> '[?]'::jsonb) OR visibility != ?", + models.PostVisibilityFriends, + models.PostVisibilitySelected, + user.ID, + models.PostVisibilitySelected, + user.ID, + models.PostVisibilityNone, + ) return tx }