2016-12-01 01:32:26 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::AccountsController < ApplicationController
|
|
|
|
before_action :require_admin!
|
2016-12-05 04:10:40 +11:00
|
|
|
before_action :set_account, except: :index
|
2016-12-01 01:32:26 +11:00
|
|
|
|
2016-12-13 23:42:10 +11:00
|
|
|
layout 'admin'
|
2016-12-01 01:32:26 +11:00
|
|
|
|
|
|
|
def index
|
2016-12-07 04:22:59 +11:00
|
|
|
@accounts = Account.alphabetic.paginate(page: params[:page], per_page: 40)
|
2016-12-05 04:10:40 +11:00
|
|
|
|
|
|
|
@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?
|
2016-12-07 04:22:59 +11:00
|
|
|
@accounts = @accounts.silenced if params[:silenced].present?
|
|
|
|
@accounts = @accounts.recent if params[:recent].present?
|
|
|
|
@accounts = @accounts.suspended if params[:suspended].present?
|
2016-12-05 04:10:40 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
2016-12-07 04:22:59 +11:00
|
|
|
def suspend
|
|
|
|
Admin::SuspensionWorker.perform_async(@account.id)
|
|
|
|
redirect_to admin_accounts_path
|
|
|
|
end
|
|
|
|
|
2017-02-15 10:22:58 +11:00
|
|
|
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
|
|
|
|
|
2016-12-05 04:10:40 +11:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_account
|
2016-12-04 05:08:07 +11:00
|
|
|
@account = Account.find(params[:id])
|
2016-12-01 01:32:26 +11:00
|
|
|
end
|
2016-12-05 04:10:40 +11:00
|
|
|
|
|
|
|
def account_params
|
2016-12-06 08:59:30 +11:00
|
|
|
params.require(:account).permit(:silenced, :suspended)
|
2016-12-05 04:10:40 +11:00
|
|
|
end
|
2016-12-01 01:32:26 +11:00
|
|
|
end
|