mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00

Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
66 lines
1.5 KiB
Ruby
66 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class Admin::Reports::ActionsController < Admin::BaseController
|
|
before_action :set_report
|
|
|
|
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'
|
|
Admin::StatusBatchAction.new(status_batch_action_params).save!
|
|
when 'silence', 'suspend'
|
|
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)
|
|
end
|
|
|
|
private
|
|
|
|
def status_batch_action_params
|
|
shared_params
|
|
.merge(status_ids: @report.status_ids)
|
|
end
|
|
|
|
def account_action_params
|
|
shared_params
|
|
.merge(target_account: @report.target_account)
|
|
end
|
|
|
|
def shared_params
|
|
{
|
|
current_account: current_account,
|
|
report_id: @report.id,
|
|
send_email_notification: !@report.spam?,
|
|
text: params[:text],
|
|
type: action_from_button,
|
|
}
|
|
end
|
|
|
|
def set_report
|
|
@report = Report.find(params[:report_id])
|
|
end
|
|
|
|
def action_from_button
|
|
if params[:delete]
|
|
'delete'
|
|
elsif params[:mark_as_sensitive]
|
|
'mark_as_sensitive'
|
|
elsif params[:silence]
|
|
'silence'
|
|
elsif params[:suspend]
|
|
'suspend'
|
|
elsif params[:moderation_action]
|
|
params[:moderation_action]
|
|
end
|
|
end
|
|
end
|