2016-12-01 01:32:26 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 05:27:03 +10:00
|
|
|
module Admin
|
|
|
|
class AccountsController < BaseController
|
2017-11-08 05:06:44 +11:00
|
|
|
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :enable, :disable, :memorialize]
|
2017-06-08 22:58:22 +10:00
|
|
|
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
|
2017-11-08 05:06:44 +11:00
|
|
|
before_action :require_local_account!, only: [:enable, :disable, :memorialize]
|
2017-06-08 22:58:22 +10:00
|
|
|
|
2017-04-11 05:27:03 +10:00
|
|
|
def index
|
2017-04-13 21:04:23 +10:00
|
|
|
@accounts = filtered_accounts.page(params[:page])
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2017-10-08 05:26:43 +11:00
|
|
|
def show
|
|
|
|
@account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
|
|
|
|
@moderation_notes = @account.targeted_moderation_notes.latest
|
|
|
|
end
|
2017-06-08 22:58:22 +10:00
|
|
|
|
|
|
|
def subscribe
|
|
|
|
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsubscribe
|
2017-08-21 09:14:40 +10:00
|
|
|
Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
|
2017-06-08 22:58:22 +10:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
2017-11-08 05:06:44 +11:00
|
|
|
def memorialize
|
|
|
|
@account.memorialize!
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
|
|
|
@account.user.enable!
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable
|
|
|
|
@account.user.disable!
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
2017-06-08 22:58:22 +10:00
|
|
|
def redownload
|
2017-07-12 01:25:49 +10:00
|
|
|
@account.reset_avatar!
|
|
|
|
@account.reset_header!
|
2017-06-08 22:58:22 +10:00
|
|
|
@account.save!
|
|
|
|
|
|
|
|
redirect_to admin_account_path(@account.id)
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-06-08 22:58:22 +10: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-11-08 05:06:44 +11:00
|
|
|
def require_local_account!
|
|
|
|
redirect_to admin_account_path(@account.id) unless @account.local? && @account.user.present?
|
|
|
|
end
|
|
|
|
|
2017-04-13 21:04:23 +10:00
|
|
|
def filtered_accounts
|
|
|
|
AccountFilter.new(filter_params).results
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2017-04-13 21:04:23 +10:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:local,
|
|
|
|
:remote,
|
|
|
|
:by_domain,
|
|
|
|
:silenced,
|
|
|
|
:recent,
|
2017-05-17 11:00:34 +10:00
|
|
|
:suspended,
|
|
|
|
:username,
|
|
|
|
:display_name,
|
|
|
|
:email,
|
|
|
|
:ip
|
2017-04-13 21:04:23 +10:00
|
|
|
)
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
2016-12-05 04:10:40 +11:00
|
|
|
end
|
2016-12-01 01:32:26 +11:00
|
|
|
end
|