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.

40 lines
921 B

  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. end
  11. private
  12. def status_params
  13. params.require(:status).permit(:sensitive)
  14. end
  15. def form_status_batch_params
  16. params.require(:form_status_batch).permit(status_ids: [])
  17. end
  18. def action_from_button
  19. if params[:nsfw_on]
  20. 'nsfw_on'
  21. elsif params[:nsfw_off]
  22. 'nsfw_off'
  23. elsif params[:delete]
  24. 'delete'
  25. end
  26. end
  27. def set_report
  28. @report = Report.find(params[:report_id])
  29. end
  30. end
  31. end