The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

46 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. class Admin::ReportsController < ApplicationController
  3. before_action :require_admin!
  4. before_action :set_report, except: [:index]
  5. layout 'admin'
  6. def index
  7. @reports = Report.includes(:account, :target_account).order('id desc').paginate(page: params[:page], per_page: 40)
  8. @reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved
  9. end
  10. def show
  11. @statuses = Status.where(id: @report.status_ids)
  12. end
  13. def resolve
  14. @report.update(action_taken: true, action_taken_by_account_id: current_account.id)
  15. redirect_to admin_report_path(@report)
  16. end
  17. def suspend
  18. Admin::SuspensionWorker.perform_async(@report.target_account.id)
  19. Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
  20. redirect_to admin_report_path(@report)
  21. end
  22. def silence
  23. @report.target_account.update(silenced: true)
  24. Report.unresolved.where(target_account: @report.target_account).update_all(action_taken: true, action_taken_by_account_id: current_account.id)
  25. redirect_to admin_report_path(@report)
  26. end
  27. def remove
  28. RemovalWorker.perform_async(params[:status_id])
  29. redirect_to admin_report_path(@report)
  30. end
  31. private
  32. def set_report
  33. @report = Report.find(params[:id])
  34. end
  35. end