diff options
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/accounts_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/admin/reports_controller.rb | 45 |
2 files changed, 60 insertions, 8 deletions
diff --git a/app/controllers/admin/accounts_controller.rb b/app/controllers/admin/accounts_controller.rb index 95107b3dc..df2c7bebf 100644 --- a/app/controllers/admin/accounts_controller.rb +++ b/app/controllers/admin/accounts_controller.rb @@ -19,19 +19,26 @@ class Admin::AccountsController < ApplicationController def show; end - def update - if @account.update(account_params) - redirect_to admin_accounts_path - else - render :show - end - end - def suspend Admin::SuspensionWorker.perform_async(@account.id) redirect_to admin_accounts_path end + def unsuspend + @account.update(suspended: false) + redirect_to admin_accounts_path + end + + def silence + @account.update(silenced: true) + redirect_to admin_accounts_path + end + + def unsilence + @account.update(silenced: false) + redirect_to admin_accounts_path + end + private def set_account diff --git a/app/controllers/admin/reports_controller.rb b/app/controllers/admin/reports_controller.rb new file mode 100644 index 000000000..67d57e4eb --- /dev/null +++ b/app/controllers/admin/reports_controller.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +class Admin::ReportsController < ApplicationController + before_action :require_admin! + before_action :set_report, except: [:index] + + layout 'admin' + + def index + @reports = Report.includes(:account, :target_account).paginate(page: params[:page], per_page: 40) + @reports = params[:action_taken].present? ? @reports.resolved : @reports.unresolved + end + + def show + @statuses = Status.where(id: @report.status_ids) + end + + def resolve + @report.update(action_taken: true) + redirect_to admin_report_path(@report) + end + + def suspend + Admin::SuspensionWorker.perform_async(@report.target_account.id) + @report.update(action_taken: true) + redirect_to admin_report_path(@report) + end + + def silence + @report.target_account.update(silenced: true) + @report.update(action_taken: true) + redirect_to admin_report_path(@report) + end + + def remove + RemovalWorker.perform_async(params[:status_id]) + redirect_to admin_report_path(@report) + end + + private + + def set_report + @report = Report.find(params[:id]) + end +end |