1cfa756d49
Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
38 lines
531 B
Ruby
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
|