🐛 Fix visibility filter

This commit is contained in:
LittleSheep 2024-08-10 17:18:55 +08:00
parent fca4032031
commit 8aa627ef43

View File

@ -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
}