# frozen_string_literal: true
module Admin
class AccountsController < BaseController
before_action :set_account, except: :index
def index
@accounts = Account.alphabetic.paginate(page: params[:page], per_page: 40)
@accounts = @accounts.local if params[:local].present?
@accounts = @accounts.remote if params[:remote].present?
@accounts = @accounts.where(domain: params[:by_domain]) if params[:by_domain].present?
@accounts = @accounts.silenced if params[:silenced].present?
@accounts = @accounts.recent if params[:recent].present?
@accounts = @accounts.suspended if params[:suspended].present?
end
def show; end
def suspend
Admin::SuspensionWorker.perform_async(@account.id)
redirect_to admin_accounts_path
def unsuspend
@account.update(suspended: false)
def silence
@account.update(silenced: true)
def unsilence
@account.update(silenced: false)
private
def set_account
@account = Account.find(params[:id])
def account_params
params.require(:account).permit(:silenced, :suspended)