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