2022-02-11 22:51:57 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::Reports::ActionsController < Admin::BaseController
|
|
|
|
before_action :set_report
|
|
|
|
|
2023-01-18 17:40:09 +02:00
|
|
|
def preview
|
|
|
|
authorize @report, :show?
|
|
|
|
@moderation_action = action_from_button
|
|
|
|
end
|
|
|
|
|
2022-02-11 22:51:57 +02:00
|
|
|
def create
|
|
|
|
authorize @report, :show?
|
|
|
|
|
|
|
|
case action_from_button
|
2022-03-01 23:20:29 +02:00
|
|
|
when 'delete', 'mark_as_sensitive'
|
2022-02-11 22:51:57 +02:00
|
|
|
status_batch_action = Admin::StatusBatchAction.new(
|
|
|
|
type: action_from_button,
|
|
|
|
status_ids: @report.status_ids,
|
|
|
|
current_account: current_account,
|
|
|
|
report_id: @report.id,
|
2023-01-18 17:40:09 +02:00
|
|
|
send_email_notification: !@report.spam?,
|
|
|
|
text: params[:text]
|
2022-02-11 22:51:57 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
status_batch_action.save!
|
|
|
|
when 'silence', 'suspend'
|
|
|
|
account_action = Admin::AccountAction.new(
|
|
|
|
type: action_from_button,
|
|
|
|
report_id: @report.id,
|
|
|
|
target_account: @report.target_account,
|
|
|
|
current_account: current_account,
|
2023-01-18 17:40:09 +02:00
|
|
|
send_email_notification: !@report.spam?,
|
|
|
|
text: params[:text]
|
2022-02-11 22:51:57 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
account_action.save!
|
2023-01-18 17:40:09 +02:00
|
|
|
else
|
|
|
|
return redirect_to admin_report_path(@report), alert: I18n.t('admin.reports.unknown_action_msg', action: action_from_button)
|
2022-02-11 22:51:57 +02:00
|
|
|
end
|
|
|
|
|
2023-01-18 17:40:09 +02:00
|
|
|
redirect_to admin_reports_path, notice: I18n.t('admin.reports.processed_msg', id: @report.id)
|
2022-02-11 22:51:57 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:report_id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_from_button
|
|
|
|
if params[:delete]
|
|
|
|
'delete'
|
2022-03-01 23:20:29 +02:00
|
|
|
elsif params[:mark_as_sensitive]
|
|
|
|
'mark_as_sensitive'
|
2022-02-11 22:51:57 +02:00
|
|
|
elsif params[:silence]
|
|
|
|
'silence'
|
|
|
|
elsif params[:suspend]
|
|
|
|
'suspend'
|
2023-01-18 17:40:09 +02:00
|
|
|
elsif params[:moderation_action]
|
|
|
|
params[:moderation_action]
|
2022-02-11 22:51:57 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|