about summary refs log tree commit diff
path: root/app/controllers/admin
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-02-11 21:53:20 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-02-11 21:53:20 +0100
commit51cad4f7fba199cdcda3ba18b68a25312e21c256 (patch)
tree15e40a919e3c7984db95e2be5a21098b0a086886 /app/controllers/admin
parent776e337b8d2aa66440bc4565617b5440ca781e1a (diff)
parentd0fcf07436d158bcac2617d076a83d0aa49c39e6 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/reports/actions_controller.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/controllers/admin/reports/actions_controller.rb b/app/controllers/admin/reports/actions_controller.rb
new file mode 100644
index 000000000..05a4fb63d
--- /dev/null
+++ b/app/controllers/admin/reports/actions_controller.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+class Admin::Reports::ActionsController < Admin::BaseController
+  before_action :set_report
+
+  def create
+    authorize @report, :show?
+
+    case action_from_button
+    when 'delete'
+      status_batch_action = Admin::StatusBatchAction.new(
+        type: action_from_button,
+        status_ids: @report.status_ids,
+        current_account: current_account,
+        report_id: @report.id,
+        send_email_notification: !@report.spam?
+      )
+
+      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,
+        send_email_notification: !@report.spam?
+      )
+
+      account_action.save!
+    end
+
+    redirect_to admin_reports_path
+  end
+
+  private
+
+  def set_report
+    @report = Report.find(params[:report_id])
+  end
+
+  def action_from_button
+    if params[:delete]
+      'delete'
+    elsif params[:silence]
+      'silence'
+    elsif params[:suspend]
+      'suspend'
+    end
+  end
+end