2016-11-30 14:32:26 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
module Admin
|
|
|
|
class AccountsController < BaseController
|
2017-06-08 12:58:22 +00:00
|
|
|
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload]
|
|
|
|
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
|
|
|
|
|
2017-04-10 19:27:03 +00:00
|
|
|
def index
|
2017-04-13 11:04:23 +00:00
|
|
|
@accounts = filtered_accounts.page(params[:page])
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
|
|
|
|
2017-06-08 12:58:22 +00:00
|
|
|
def show; end
|
|
|
|
|
|
|
|
def subscribe
|
|
|
|
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsubscribe
|
2017-08-20 23:14:40 +00:00
|
|
|
Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
|
2017-06-08 12:58:22 +00:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def redownload
|
2017-07-11 15:25:49 +00:00
|
|
|
@account.reset_avatar!
|
|
|
|
@account.reset_header!
|
2017-06-08 12:58:22 +00:00
|
|
|
@account.save!
|
|
|
|
|
|
|
|
redirect_to admin_account_path(@account.id)
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-06-08 12:58:22 +00:00
|
|
|
def set_account
|
|
|
|
@account = Account.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def require_remote_account!
|
|
|
|
redirect_to admin_account_path(@account.id) if @account.local?
|
|
|
|
end
|
|
|
|
|
2017-04-13 11:04:23 +00:00
|
|
|
def filtered_accounts
|
|
|
|
AccountFilter.new(filter_params).results
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
|
|
|
|
2017-04-13 11:04:23 +00:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:local,
|
|
|
|
:remote,
|
|
|
|
:by_domain,
|
|
|
|
:silenced,
|
|
|
|
:recent,
|
2017-05-17 01:00:34 +00:00
|
|
|
:suspended,
|
|
|
|
:username,
|
|
|
|
:display_name,
|
|
|
|
:email,
|
|
|
|
:ip
|
2017-04-13 11:04:23 +00:00
|
|
|
)
|
2017-04-10 19:27:03 +00:00
|
|
|
end
|
2016-12-04 17:10:40 +00:00
|
|
|
end
|
2016-11-30 14:32:26 +00:00
|
|
|
end
|