Chatwoot/app/policies/inbox_policy.rb
Sojan Jose 1cfa756d49
Chore: APIs for agent bots (#676)
Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
2020-04-07 10:41:18 +05:30

38 lines
531 B
Ruby

class InboxPolicy < ApplicationPolicy
class Scope
attr_reader :user, :scope
def initialize(user, scope)
@user = user
@scope = scope
end
def resolve
if user.administrator?
scope.all
elsif user.agent?
user.assigned_inboxes
end
end
end
def index?
true
end
def create?
@user.administrator?
end
def update?
@user.administrator?
end
def destroy?
@user.administrator?
end
def set_agent_bot?
@user.administrator?
end
end