mirror of
https://github.com/discourse/discourse.git
synced 2026-08-12 05:55:39 -05:00
SECURITY: Users can only bookmark posts which they can see.
This commit is contained in:
@@ -352,8 +352,24 @@ SQL
|
||||
builder.where('a.action_type <> :pending', pending: UserAction::PENDING)
|
||||
end
|
||||
|
||||
if !guardian.can_see_private_messages?(user_id) || ignore_private_messages
|
||||
builder.where("t.archetype != :archetype", archetype: Archetype::private_message)
|
||||
if !guardian.can_see_private_messages?(user_id) || ignore_private_messages || !guardian.user
|
||||
builder.where("t.archetype <> :private_message", private_message: Archetype::private_message)
|
||||
else
|
||||
unless guardian.is_admin?
|
||||
sql = <<~SQL
|
||||
t.archetype <> :private_message OR
|
||||
EXISTS (
|
||||
SELECT 1 FROM topic_allowed_users tu WHERE tu.topic_id = t.id AND tu.user_id = :current_user_id
|
||||
) OR
|
||||
EXISTS (
|
||||
SELECT 1 FROM topic_allowed_groups tg WHERE tg.topic_id = t.id AND tg.group_id IN (
|
||||
SELECT group_id FROM group_users gu WHERE gu.user_id = :current_user_id
|
||||
)
|
||||
)
|
||||
SQL
|
||||
|
||||
builder.where(sql, private_message: Archetype::private_message, current_user_id: guardian.user.id)
|
||||
end
|
||||
end
|
||||
|
||||
unless guardian.is_admin?
|
||||
|
||||
Reference in New Issue
Block a user