Chat button in user card should hide if disable direct message

Hello, I allow user to chat in channel but disable them in direct message. In this case, a non-staff user can still see Chat button in others’ user card. But they may get wrong message after click it.

I read the code, the button is shown if can_chat_user. This is determined by following code.

# plugins/chat/plugin.rb
  add_to_serializer(:user_card, :can_chat_user) 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)
  end

and

# plugins/chat/lib/guardian_extentions.rb

 def can_chat?(user)
    return false unless user
    user.staff? || user.in_any_groups?(Chat.allowed_group_ids)
  end
2 Likes

Thanks for reporting this! I will add it to our list to fix this up.

1 Like

Good catch thanks, that should be fixed by:

:+1:

4 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.