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.

51 lines
1.4 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 suspend
  17. Admin::SuspensionWorker.perform_async(@account.id)
  18. redirect_to admin_accounts_path
  19. end
  20. def unsuspend
  21. @account.update(suspended: false)
  22. redirect_to admin_accounts_path
  23. end
  24. def silence
  25. @account.update(silenced: true)
  26. redirect_to admin_accounts_path
  27. end
  28. def unsilence
  29. @account.update(silenced: false)
  30. redirect_to admin_accounts_path
  31. end
  32. private
  33. def set_account
  34. @account = Account.find(params[:id])
  35. end
  36. def account_params
  37. params.require(:account).permit(:silenced, :suspended)
  38. end
  39. end