reported_statuses_controller.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. module Admin
  3. class ReportedStatusesController < BaseController
  4. before_action :set_report
  5. def create
  6. authorize :status, :update?
  7. @form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account, action: action_from_button))
  8. flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
  9. redirect_to admin_report_path(@report)
  10. rescue ActionController::ParameterMissing
  11. flash[:alert] = I18n.t('admin.statuses.no_status_selected')
  12. redirect_to admin_report_path(@report)
  13. end
  14. private
  15. def status_params
  16. params.require(:status).permit(:sensitive)
  17. end
  18. def form_status_batch_params
  19. params.require(:form_status_batch).permit(status_ids: [])
  20. end
  21. def action_from_button
  22. if params[:nsfw_on]
  23. 'nsfw_on'
  24. elsif params[:nsfw_off]
  25. 'nsfw_off'
  26. elsif params[:delete]
  27. 'delete'
  28. end
  29. end
  30. def set_report
  31. @report = Report.find(params[:report_id])
  32. end
  33. end
  34. end