You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class Admin::Reports::ActionsController < Admin::BaseController
  3. before_action :set_report
  4. def create
  5. authorize @report, :show?
  6. case action_from_button
  7. when 'delete', 'mark_as_sensitive'
  8. status_batch_action = Admin::StatusBatchAction.new(
  9. type: action_from_button,
  10. status_ids: @report.status_ids,
  11. current_account: current_account,
  12. report_id: @report.id,
  13. send_email_notification: !@report.spam?
  14. )
  15. status_batch_action.save!
  16. when 'silence', 'suspend'
  17. account_action = Admin::AccountAction.new(
  18. type: action_from_button,
  19. report_id: @report.id,
  20. target_account: @report.target_account,
  21. current_account: current_account,
  22. send_email_notification: !@report.spam?
  23. )
  24. account_action.save!
  25. end
  26. redirect_to admin_reports_path
  27. end
  28. private
  29. def set_report
  30. @report = Report.find(params[:report_id])
  31. end
  32. def action_from_button
  33. if params[:delete]
  34. 'delete'
  35. elsif params[:mark_as_sensitive]
  36. 'mark_as_sensitive'
  37. elsif params[:silence]
  38. 'silence'
  39. elsif params[:suspend]
  40. 'suspend'
  41. end
  42. end
  43. end