diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index dd2ea0b..01dbd2c 100644 --- a/pkg/internal/services/posts.go +++ b/pkg/internal/services/posts.go @@ -27,10 +27,16 @@ func FilterPostWithUserContext(tx *gorm.DB, user *models.Account) *gorm.DB { ) // TODO Blocked by dealer, need support get friend list - tx = tx.Where("visibility != ? OR visibility != ?", FriendsVisibility, NoneVisibility). - Or("visibility = ? AND ?", SelectedVisibility, datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID)))). - Or("visibility = ? AND NOT ?", SelectedVisibility, datatypes.JSONQuery("invisible_users").HasKey(strconv.Itoa(int(user.ID)))). - Or("author_id = ?", user.ID) + tx = tx.Where( + "(visibility != ? OR visibility != ? OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR author_id = ?)", + FriendsVisibility, + NoneVisibility, + SelectedVisibility, + datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID))), + SelectedVisibility, + datatypes.JSONQuery("invisible_users").HasKey(strconv.Itoa(int(user.ID))), + user.ID, + ) return tx }