🐛 Fix visibility filter will filter user own psots

This commit is contained in:
LittleSheep 2024-07-30 17:59:14 +08:00
parent 830484fee1
commit e9c7921d39

View File

@ -29,7 +29,8 @@ 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("visibility != ? OR visibility != ?", FriendsVisibility, NoneVisibility).
Or("visibility = ? AND ?", SelectedVisibility, datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID)))). 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("visibility = ? AND NOT ?", SelectedVisibility, datatypes.JSONQuery("invisible_users").HasKey(strconv.Itoa(int(user.ID)))).
Or("author_id = ?", user.ID)
return tx return tx
} }