From 0fd742ffd22cdc3aba0924c21bb82164df975f2b Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Mon, 29 Jul 2024 23:07:12 +0800 Subject: [PATCH] :bug: Fix column naming issue in where statement --- pkg/internal/models/posts.go | 4 ++-- pkg/internal/services/posts.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/internal/models/posts.go b/pkg/internal/models/posts.go index da53483..b817745 100644 --- a/pkg/internal/models/posts.go +++ b/pkg/internal/models/posts.go @@ -38,8 +38,8 @@ type Post struct { RepostTo *Post `json:"repost_to" gorm:"foreignKey:RepostID"` Realm *Realm `json:"realm"` - VisibleUsers datatypes.JSONSlice[uint] `json:"visible_users"` - InvisibleUsers datatypes.JSONSlice[uint] `json:"invisible_users"` + VisibleUsers datatypes.JSONSlice[uint] `json:"visible_users_list"` + InvisibleUsers datatypes.JSONSlice[uint] `json:"invisible_users_list"` Visibility PostVisibilityLevel `json:"visibility"` EditedAt *time.Time `json:"edited_at"` diff --git a/pkg/internal/services/posts.go b/pkg/internal/services/posts.go index 866ff44..bb004f0 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_list::jsonb[])", models.PostVisibilitySelected, user.ID) - tx = tx.Where("visibility = ? AND NOT ( ? = ANY (invisible_users_list::jsonb[]) )", models.PostVisibilitySelected, user.ID) + 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 != ?", models.PostVisibilityNone) return tx