mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Use guardian user for can_chat? (#19418)
Instead of passing `user` to `guardian.can_chat?`, we can just use the inner `@user` that is part of the guardian instance already to determine whether that user can chat, since this is how it works for all other usages of guardian even within chat.
This commit is contained in:
@ -386,7 +386,7 @@ after_initialize do
|
||||
return false if !SiteSetting.chat_enabled
|
||||
return false if scope.user.blank?
|
||||
|
||||
scope.user.id != object.id && scope.can_chat?(scope.user) && scope.can_chat?(object)
|
||||
scope.user.id != object.id && scope.can_chat? && Guardian.new(object).can_chat?
|
||||
end
|
||||
|
||||
add_to_serializer(:current_user, :can_chat) { true }
|
||||
@ -394,7 +394,7 @@ after_initialize do
|
||||
add_to_serializer(:current_user, :include_can_chat?) do
|
||||
return @can_chat if defined?(@can_chat)
|
||||
|
||||
@can_chat = SiteSetting.chat_enabled && scope.can_chat?(object)
|
||||
@can_chat = SiteSetting.chat_enabled && scope.can_chat?
|
||||
end
|
||||
|
||||
add_to_serializer(:current_user, :has_chat_enabled) { true }
|
||||
|
Reference in New Issue
Block a user