Add AccountWarning#appeal_eligible?
method (#33526)
This commit is contained in:
parent
3a4aed9890
commit
54e2030146
6 changed files with 24 additions and 7 deletions
|
@ -27,6 +27,7 @@ class AccountWarning < ApplicationRecord
|
|||
suspend: 4_000,
|
||||
}, suffix: :action
|
||||
|
||||
APPEAL_WINDOW = 20.days
|
||||
RECENT_PERIOD = 3.months.freeze
|
||||
|
||||
normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true
|
||||
|
@ -49,6 +50,10 @@ class AccountWarning < ApplicationRecord
|
|||
overruled_at.present?
|
||||
end
|
||||
|
||||
def appeal_eligible?
|
||||
created_at >= APPEAL_WINDOW.ago
|
||||
end
|
||||
|
||||
def to_log_human_identifier
|
||||
target_account.acct
|
||||
end
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
# updated_at :datetime not null
|
||||
#
|
||||
class Appeal < ApplicationRecord
|
||||
MAX_STRIKE_AGE = 20.days
|
||||
|
||||
TEXT_LENGTH_LIMIT = 2_000
|
||||
|
||||
belongs_to :account
|
||||
|
@ -68,6 +66,6 @@ class Appeal < ApplicationRecord
|
|||
private
|
||||
|
||||
def validate_time_frame
|
||||
errors.add(:base, I18n.t('strikes.errors.too_late')) if strike.created_at < MAX_STRIKE_AGE.ago
|
||||
errors.add(:base, I18n.t('strikes.errors.too_late')) unless strike.appeal_eligible?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class AccountWarningPolicy < ApplicationPolicy
|
|||
end
|
||||
|
||||
def appeal?
|
||||
target? && record.created_at >= Appeal::MAX_STRIKE_AGE.ago
|
||||
target? && record.appeal_eligible?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue