mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: access to category chat only when user can create post (#19488)
Previously, restricted category chat channel was available for all groups - even `readonly`. From now on, only user who belong to group with `create_post` or `full` permissions can access that chat channel.
This commit is contained in:

committed by
GitHub

parent
4adb457ced
commit
09d15d4c7f
@ -80,7 +80,7 @@ module Chat::GuardianExtensions
|
||||
is_staff? || @user.has_trust_level?(TrustLevel[4])
|
||||
end
|
||||
|
||||
def can_see_chat_channel?(chat_channel)
|
||||
def can_preview_chat_channel?(chat_channel)
|
||||
return false unless chat_channel.chatable
|
||||
|
||||
if chat_channel.direct_message_channel?
|
||||
@ -92,6 +92,12 @@ module Chat::GuardianExtensions
|
||||
end
|
||||
end
|
||||
|
||||
def can_join_chat_channel?(chat_channel)
|
||||
return false if anonymous?
|
||||
can_preview_chat_channel?(chat_channel) &&
|
||||
(chat_channel.direct_message_channel? || can_post_in_category?(chat_channel.chatable))
|
||||
end
|
||||
|
||||
def can_flag_chat_messages?
|
||||
return false if @user.silenced?
|
||||
return true if @user.staff?
|
||||
@ -102,7 +108,7 @@ module Chat::GuardianExtensions
|
||||
def can_flag_in_chat_channel?(chat_channel)
|
||||
return false if !can_modify_channel_message?(chat_channel)
|
||||
|
||||
can_see_chat_channel?(chat_channel)
|
||||
can_join_chat_channel?(chat_channel)
|
||||
end
|
||||
|
||||
def can_flag_chat_message?(chat_message)
|
||||
|
Reference in New Issue
Block a user