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.

44 lines
1.2 KiB

  1. # frozen_string_literal: true
  2. class Admin::AccountsController < ApplicationController
  3. before_action :require_admin!
  4. before_action :set_account, except: :index
  5. layout 'admin'
  6. def index
  7. @accounts = Account.alphabetic.paginate(page: params[:page], per_page: 40)
  8. @accounts = @accounts.local if params[:local].present?
  9. @accounts = @accounts.remote if params[:remote].present?
  10. @accounts = @accounts.where(domain: params[:by_domain]) if params[:by_domain].present?
  11. @accounts = @accounts.silenced if params[:silenced].present?
  12. @accounts = @accounts.recent if params[:recent].present?
  13. @accounts = @accounts.suspended if params[:suspended].present?
  14. end
  15. def show; end
  16. def update
  17. if @account.update(account_params)
  18. redirect_to admin_accounts_path
  19. else
  20. render :show
  21. end
  22. end
  23. def suspend
  24. Admin::SuspensionWorker.perform_async(@account.id)
  25. redirect_to admin_accounts_path
  26. end
  27. private
  28. def set_account
  29. @account = Account.find(params[:id])
  30. end
  31. def account_params
  32. params.require(:account).permit(:silenced, :suspended)
  33. end
  34. end