2019-08-14 09:48:44 +00:00
|
|
|
class InboxPolicy < ApplicationPolicy
|
|
|
|
class Scope
|
2020-05-26 17:08:48 +00:00
|
|
|
attr_reader :user_context, :user, :scope, :account, :account_user
|
2019-08-14 09:48:44 +00:00
|
|
|
|
2020-05-26 17:08:48 +00:00
|
|
|
def initialize(user_context, scope)
|
|
|
|
@user_context = user_context
|
|
|
|
@user = user_context[:user]
|
|
|
|
@account = user_context[:account]
|
|
|
|
@account_user = user_context[:account_user]
|
2019-08-14 09:48:44 +00:00
|
|
|
@scope = scope
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve
|
2021-06-11 06:14:31 +00:00
|
|
|
user.assigned_inboxes
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def index?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-06-11 06:14:31 +00:00
|
|
|
def show?
|
|
|
|
# FIXME: for agent bots, lets bring this validation to policies as well in future
|
|
|
|
return true if @user.blank?
|
|
|
|
|
|
|
|
Current.user.assigned_inboxes.include? record
|
|
|
|
end
|
|
|
|
|
2021-04-20 08:16:20 +00:00
|
|
|
def assignable_agents?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-06-01 17:04:25 +00:00
|
|
|
def agent_bot?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2021-04-29 16:53:32 +00:00
|
|
|
def campaigns?
|
|
|
|
@account_user.administrator?
|
|
|
|
end
|
|
|
|
|
2019-11-30 12:03:42 +00:00
|
|
|
def create?
|
2020-05-26 17:08:48 +00:00
|
|
|
@account_user.administrator?
|
2019-11-30 12:03:42 +00:00
|
|
|
end
|
|
|
|
|
2019-12-28 16:26:42 +00:00
|
|
|
def update?
|
2020-05-26 17:08:48 +00:00
|
|
|
@account_user.administrator?
|
2019-12-28 16:26:42 +00:00
|
|
|
end
|
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
def destroy?
|
2020-05-26 17:08:48 +00:00
|
|
|
@account_user.administrator?
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|
2020-04-07 05:11:18 +00:00
|
|
|
|
|
|
|
def set_agent_bot?
|
2020-05-26 17:08:48 +00:00
|
|
|
@account_user.administrator?
|
2020-04-07 05:11:18 +00:00
|
|
|
end
|
2021-08-31 09:42:05 +00:00
|
|
|
|
|
|
|
def avatar?
|
|
|
|
@account_user.administrator?
|
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|