🐛 Bug fixes on visibility

This commit is contained in:
LittleSheep 2024-10-11 00:04:41 +08:00
parent aca0aa97aa
commit f5544e73f3

View File

@ -29,11 +29,11 @@ func FilterPostWithUserContext(tx *gorm.DB, user *models.Account) *gorm.DB {
) )
friends, _ := ListAccountFriends(*user) friends, _ := ListAccountFriends(*user)
friendAllowList := lo.Map(friends, func(item models.Account, index int) uint { allowlist := lo.Map(friends, func(item models.Account, index int) uint {
return item.ID return item.ID
}) })
blocked, _ := ListAccountBlockedUsers(*user) blocked, _ := ListAccountBlockedUsers(*user)
blockedDisallowList := lo.Map(blocked, func(item models.Account, index int) uint { blocklist := lo.Map(blocked, func(item models.Account, index int) uint {
return item.ID return item.ID
}) })
@ -41,8 +41,8 @@ func FilterPostWithUserContext(tx *gorm.DB, user *models.Account) *gorm.DB {
"(visibility != ? OR (visibility != ? AND author_id IN ? AND author_id NOT IN ?) OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR author_id = ?)", "(visibility != ? OR (visibility != ? AND author_id IN ? AND author_id NOT IN ?) OR (visibility = ? AND ?) OR (visibility = ? AND NOT ?) OR author_id = ?)",
NoneVisibility, NoneVisibility,
FriendsVisibility, FriendsVisibility,
friendAllowList, allowlist,
blockedDisallowList, blocklist,
SelectedVisibility, SelectedVisibility,
datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID))), datatypes.JSONQuery("visible_users").HasKey(strconv.Itoa(int(user.ID))),
FilteredVisibility, FilteredVisibility,