Chatwoot/app/policies/macro_policy.rb

42 lines
578 B
Ruby
Raw Permalink Normal View History

2022-07-19 12:07:00 +00:00
class MacroPolicy < ApplicationPolicy
def index?
true
end
def create?
true
end
def show?
@record.global? || author?
2022-07-19 12:07:00 +00:00
end
def update?
author? || (@account_user.administrator? && @record.global?)
2022-07-19 12:07:00 +00:00
end
def destroy?
author? || orphan_record?
2022-07-19 12:07:00 +00:00
end
def execute?
@record.global? || author?
end
def attach_file?
true
end
private
def author?
@record.created_by == @account_user.user
end
def orphan_record?
return @account_user.administrator? if @record.created_by.nil? && @record.global?
false
end
2022-07-19 12:07:00 +00:00
end