rootstrap/activeadmin-chat

View on GitHub
app/channels/active_admin/chat/admin_channel.rb

Summary

Maintainability
A
0 mins
Test Coverage
module ActiveAdmin
  module Chat
    class AdminChannel < ActiveAdmin::Chat::BaseChannel
      private

      def conversation
        return unless admin? && conversation_id.present?

        @conversation ||= ActiveAdmin::Chat.conversation_klass.find_by(id: conversation_id)
      end

      def admin?
        current_user.instance_of?(ActiveAdmin::Chat.admin_user_klass)
      end

      def conversation_id
        params[:conversation_id]
      end
    end
  end
end