logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

reported_statuses_controller.rb (1196B)


  1. # frozen_string_literal: true
  2. module Admin
  3. class ReportedStatusesController < BaseController
  4. before_action :set_report
  5. before_action :set_status, only: [:update, :destroy]
  6. def create
  7. authorize :status, :update?
  8. @form = Form::StatusBatch.new(form_status_batch_params.merge(current_account: current_account))
  9. flash[:alert] = I18n.t('admin.statuses.failed_to_execute') unless @form.save
  10. redirect_to admin_report_path(@report)
  11. end
  12. def update
  13. authorize @status, :update?
  14. @status.update!(status_params)
  15. log_action :update, @status
  16. redirect_to admin_report_path(@report)
  17. end
  18. def destroy
  19. authorize @status, :destroy?
  20. RemovalWorker.perform_async(@status.id)
  21. log_action :destroy, @status
  22. render json: @status
  23. end
  24. private
  25. def status_params
  26. params.require(:status).permit(:sensitive)
  27. end
  28. def form_status_batch_params
  29. params.require(:form_status_batch).permit(:action, status_ids: [])
  30. end
  31. def set_report
  32. @report = Report.find(params[:report_id])
  33. end
  34. def set_status
  35. @status = @report.statuses.find(params[:id])
  36. end
  37. end
  38. end