🐛 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 // TODO Blocked by dealer, need support get friend list
tx = tx.Where("visibility != ? OR visibility != ?", FriendsVisibility, NoneVisibility). tx = tx.Where(
Or("visibility = ? AND ?", SelectedVisibility, datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID)))). "(visibility != ? OR visibility != ? OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR author_id = ?)",
Or("visibility = ? AND NOT ?", SelectedVisibility, datatypes.JSONQuery("invisible_users").HasKey(strconv.Itoa(int(user.ID)))). FriendsVisibility,
Or("author_id = ?", user.ID) 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 return tx
} }