2019-08-14 09:48:44 +00:00
|
|
|
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
|
|
|
|
|
2019-11-30 12:03:42 +00:00
|
|
|
def create?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
|
|
|
|
2019-12-28 16:26:42 +00:00
|
|
|
def update?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
def destroy?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
2020-04-07 05:11:18 +00:00
|
|
|
|
|
|
|
def set_agent_bot?
|
|
|
|
@user.administrator?
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|