mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:41:24 +08:00
FIX: hide chat btn from user card when chat disabled (#26237)
The issue: When the current user disables chat from within user preferences, the chat button still appears when clicking another user’s profile picture to open the user card. This is also the case when the current user has chat enabled but the target user has disabled chat. After this change: - when a user disables chat in preferences, the chat button should not be displayed when opening a user card or visiting profiles of other users. - when chat is enabled in preferences but another user disables chat, the chat button should not appear on their user card or profile
This commit is contained in:
@ -147,9 +147,10 @@ after_initialize do
|
||||
|
||||
add_to_serializer(:user_card, :can_chat_user) do
|
||||
return false if !SiteSetting.chat_enabled
|
||||
return false if scope.user.blank?
|
||||
return false if scope.user.blank? || scope.user.id == object.id
|
||||
return false if !scope.user.user_option.chat_enabled || !object.user_option.chat_enabled
|
||||
|
||||
scope.user.id != object.id && scope.can_chat? && Guardian.new(object).can_chat?
|
||||
scope.can_direct_message? && Guardian.new(object).can_chat?
|
||||
end
|
||||
|
||||
add_to_serializer(
|
||||
@ -166,7 +167,7 @@ after_initialize do
|
||||
:can_direct_message,
|
||||
include_condition: -> do
|
||||
return @can_direct_message if defined?(@can_direct_message)
|
||||
@can_direct_message = SiteSetting.chat_enabled && scope.can_direct_message?
|
||||
@can_direct_message = include_has_chat_enabled? && scope.can_direct_message?
|
||||
end,
|
||||
) { true }
|
||||
|
||||
|
Reference in New Issue
Block a user