mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 09:21:11 +00:00
Merge ac5d8f9bb0
into 14cb5ff881
This commit is contained in:
commit
766a81f0c5
|
@ -2,22 +2,29 @@
|
|||
|
||||
class Admin::Reports::ActionsController < Admin::BaseController
|
||||
before_action :set_report
|
||||
before_action :verify_report_permissions
|
||||
before_action :unknown_action, unless: :valid_button_action?, only: :create
|
||||
|
||||
STATUS_ACTIONS = %w(
|
||||
delete
|
||||
mark_as_sensitive
|
||||
).freeze
|
||||
|
||||
ACCOUNT_ACTIONS = %w(
|
||||
silence
|
||||
suspend
|
||||
).freeze
|
||||
|
||||
def preview
|
||||
authorize @report, :show?
|
||||
@moderation_action = action_from_button
|
||||
end
|
||||
|
||||
def create
|
||||
authorize @report, :show?
|
||||
|
||||
case action_from_button
|
||||
when 'delete', 'mark_as_sensitive'
|
||||
when *STATUS_ACTIONS
|
||||
Admin::StatusBatchAction.new(status_batch_action_params).save!
|
||||
when 'silence', 'suspend'
|
||||
when *ACCOUNT_ACTIONS
|
||||
Admin::AccountAction.new(account_action_params).save!
|
||||
else
|
||||
return redirect_to admin_report_path(@report), alert: I18n.t('admin.reports.unknown_action_msg', action: action_from_button)
|
||||
end
|
||||
|
||||
redirect_to admin_reports_path, notice: I18n.t('admin.reports.processed_msg', id: @report.id)
|
||||
|
@ -25,6 +32,20 @@ class Admin::Reports::ActionsController < Admin::BaseController
|
|||
|
||||
private
|
||||
|
||||
def verify_report_permissions
|
||||
authorize @report, :show?
|
||||
end
|
||||
|
||||
def unknown_action
|
||||
redirect_to admin_report_path(@report), alert: t('admin.reports.unknown_action_msg', action: action_from_button)
|
||||
end
|
||||
|
||||
def valid_button_action?
|
||||
[STATUS_ACTIONS, ACCOUNT_ACTIONS]
|
||||
.flatten
|
||||
.include?(action_from_button)
|
||||
end
|
||||
|
||||
def status_batch_action_params
|
||||
shared_params
|
||||
.merge(status_ids: @report.status_ids)
|
||||
|
|
Loading…
Reference in New Issue
Block a user