diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-09-11 16:32:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-11 16:32:44 +0200 |
commit | c5d37f18cb3f4d6212fb8f3e1c4e1e027f677ec5 (patch) | |
tree | 190b0c85e6e8f3880d9d291781d9a73185e0252c /app/models/admin | |
parent | 4fe127664b0ae22a528b4a4467ab2de92e3da3ef (diff) |
Change deletes to preserve soft-deleted statuses in unresolved reports (#11805)
Change all account actions except "none" to resolve all unresolved reports Refactor `SuspendAccountService` to be more readable
Diffstat (limited to 'app/models/admin')
-rw-r--r-- | app/models/admin/account_action.rb | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/app/models/admin/account_action.rb b/app/models/admin/account_action.rb index c7da8b52c..b30a82369 100644 --- a/app/models/admin/account_action.rb +++ b/app/models/admin/account_action.rb @@ -83,19 +83,23 @@ class Admin::AccountAction # A log entry is only interesting if the warning contains # custom text from someone. Otherwise it's just noise. + log_action(:create, warning) if warning.text.present? end def process_reports! - return if report_id.blank? + # If we're doing "mark as resolved" on a single report, + # then we want to keep other reports open in case they + # contain new actionable information. + # + # Otherwise, we will mark all unresolved reports about + # the account as resolved. - authorize(report, :update?) + reports.each { |report| authorize(report, :update?) } - if type == 'none' + reports.each do |report| log_action(:resolve, report) report.resolve!(current_account) - else - Report.where(target_account: target_account).unresolved.update_all(action_taken: true, action_taken_by_account_id: current_account.id) end end @@ -141,6 +145,16 @@ class Admin::AccountAction @report.status_ids if @report && include_statuses end + def reports + @reports ||= begin + if type == 'none' && with_report? + [report] + else + Report.where(target_account: target_account).unresolved + end + end + end + def warning_preset @warning_preset ||= AccountWarningPreset.find(warning_preset_id) if warning_preset_id.present? end |