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
# 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