diff options
author | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-02-25 12:35:11 -0600 |
commit | ad1733ea294c6049336a9aeeb7ff96c8fea22cfa (patch) | |
tree | 306ff2d36a8bce82039890c4327f7d7bf37583dc /app/policies | |
parent | c5f289e8ef7ec1592d068ac797add7332343820d (diff) | |
parent | e48eaf64cc7cb0cfab388331c4823ee5fb580d59 (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/account_warning_policy.rb | 17 | ||||
-rw-r--r-- | app/policies/appeal_policy.rb | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/app/policies/account_warning_policy.rb b/app/policies/account_warning_policy.rb new file mode 100644 index 000000000..65707dfa7 --- /dev/null +++ b/app/policies/account_warning_policy.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class AccountWarningPolicy < ApplicationPolicy + def show? + target? || staff? + end + + def appeal? + target? && record.created_at >= Appeal::MAX_STRIKE_AGE.ago + end + + private + + def target? + record.target_account_id == current_account&.id + end +end diff --git a/app/policies/appeal_policy.rb b/app/policies/appeal_policy.rb new file mode 100644 index 000000000..a25187172 --- /dev/null +++ b/app/policies/appeal_policy.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class AppealPolicy < ApplicationPolicy + def index? + staff? + end + + def approve? + record.pending? && staff? + end + + alias reject? approve? +end |