2016-11-30 23:32:26 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
module Admin
|
|
|
|
class AccountsController < BaseController
|
2019-03-14 13:28:30 +09:00
|
|
|
before_action :set_account, only: [:show, :subscribe, :unsubscribe, :redownload, :remove_avatar, :remove_header, :enable, :unsilence, :unsuspend, :memorialize, :approve, :reject]
|
2017-06-08 21:58:22 +09:00
|
|
|
before_action :require_remote_account!, only: [:subscribe, :unsubscribe, :redownload]
|
2019-03-14 13:28:30 +09:00
|
|
|
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
|
2017-06-08 21:58:22 +09:00
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
def index
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize :account, :index?
|
2017-04-13 20:04:23 +09:00
|
|
|
@accounts = filtered_accounts.page(params[:page])
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
|
2017-10-08 03:26:43 +09:00
|
|
|
def show
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account, :show?
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
|
2017-10-08 03:26:43 +09:00
|
|
|
@account_moderation_note = current_account.account_moderation_notes.new(target_account: @account)
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
@moderation_notes = @account.targeted_moderation_notes.latest
|
|
|
|
@warnings = @account.targeted_account_warnings.latest.custom
|
2017-10-08 03:26:43 +09:00
|
|
|
end
|
2017-06-08 21:58:22 +09:00
|
|
|
|
|
|
|
def subscribe
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account, :subscribe?
|
2017-06-08 21:58:22 +09:00
|
|
|
Pubsubhubbub::SubscribeWorker.perform_async(@account.id)
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsubscribe
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account, :unsubscribe?
|
2017-08-21 08:14:40 +09:00
|
|
|
Pubsubhubbub::UnsubscribeWorker.perform_async(@account.id)
|
2017-06-08 21:58:22 +09:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
2017-11-08 03:06:44 +09:00
|
|
|
def memorialize
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account, :memorialize?
|
2017-11-08 03:06:44 +09:00
|
|
|
@account.memorialize!
|
2017-11-24 10:05:53 +09:00
|
|
|
log_action :memorialize, @account
|
2017-11-08 03:06:44 +09:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account.user, :enable?
|
2017-11-08 03:06:44 +09:00
|
|
|
@account.user.enable!
|
2017-11-24 10:05:53 +09:00
|
|
|
log_action :enable, @account.user
|
2017-11-08 03:06:44 +09:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
2019-03-14 13:28:30 +09:00
|
|
|
def approve
|
|
|
|
authorize @account.user, :approve?
|
|
|
|
@account.user.approve!
|
|
|
|
redirect_to admin_accounts_path(pending: '1')
|
|
|
|
end
|
|
|
|
|
|
|
|
def reject
|
|
|
|
authorize @account.user, :reject?
|
|
|
|
SuspendAccountService.new.call(@account, including_user: true, destroy: true)
|
|
|
|
redirect_to admin_accounts_path(pending: '1')
|
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-23 04:02:09 +09:00
|
|
|
def unsilence
|
|
|
|
authorize @account, :unsilence?
|
|
|
|
@account.unsilence!
|
|
|
|
log_action :unsilence, @account
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def unsuspend
|
|
|
|
authorize @account, :unsuspend?
|
|
|
|
@account.unsuspend!
|
|
|
|
log_action :unsuspend, @account
|
2017-11-08 03:06:44 +09:00
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
end
|
|
|
|
|
2017-06-08 21:58:22 +09:00
|
|
|
def redownload
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @account, :redownload?
|
|
|
|
|
2018-12-28 11:38:41 +09:00
|
|
|
@account.update!(last_webfingered_at: nil)
|
|
|
|
ResolveAccountService.new.call(@account)
|
2017-06-08 21:58:22 +09:00
|
|
|
|
|
|
|
redirect_to admin_account_path(@account.id)
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
|
2018-04-02 20:45:07 +09: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-12 03:28:03 +09: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-11 04:27:03 +09:00
|
|
|
private
|
|
|
|
|
2017-06-08 21:58:22 +09: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 03:06:44 +09:00
|
|
|
def require_local_account!
|
|
|
|
redirect_to admin_account_path(@account.id) unless @account.local? && @account.user.present?
|
|
|
|
end
|
|
|
|
|
2017-04-13 20:04:23 +09:00
|
|
|
def filtered_accounts
|
|
|
|
AccountFilter.new(filter_params).results
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
|
2017-04-13 20:04:23 +09:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:local,
|
|
|
|
:remote,
|
|
|
|
:by_domain,
|
2018-11-26 23:53:27 +09:00
|
|
|
:active,
|
2019-03-14 13:28:30 +09:00
|
|
|
:pending,
|
2017-04-13 20:04:23 +09:00
|
|
|
:silenced,
|
2017-05-17 10:00:34 +09:00
|
|
|
:suspended,
|
|
|
|
:username,
|
|
|
|
:display_name,
|
|
|
|
:email,
|
2017-12-13 20:15:10 +09:00
|
|
|
:ip,
|
|
|
|
:staff
|
2017-04-13 20:04:23 +09:00
|
|
|
)
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
2016-12-05 02:10:40 +09:00
|
|
|
end
|
2016-11-30 23:32:26 +09:00
|
|
|
end
|