mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
38 lines
543 B
Ruby
38 lines
543 B
Ruby
class MacroPolicy < ApplicationPolicy
|
|
def index?
|
|
true
|
|
end
|
|
|
|
def create?
|
|
true
|
|
end
|
|
|
|
def show?
|
|
@record.global? || author?
|
|
end
|
|
|
|
def update?
|
|
author? || (@account_user.administrator? && @record.global?)
|
|
end
|
|
|
|
def destroy?
|
|
author? || orphan_record?
|
|
end
|
|
|
|
def execute?
|
|
@record.global? || author?
|
|
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
|
|
end
|