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
|
2021-12-06 07:48:39 +11:00
|
|
|
before_action :set_account, except: [:index, :batch]
|
2019-07-07 07:26:16 +10:00
|
|
|
before_action :require_remote_account!, only: [:redownload]
|
2019-03-14 15:28:30 +11:00
|
|
|
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
|
2017-06-08 22:58:22 +10:00
|
|
|
|
2017-04-11 05:27:03 +10:00
|
|
|
def index
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize :account, :index?
|
2021-12-06 07:48:39 +11:00
|
|
|
|
2017-04-13 21:04:23 +10:00
|
|
|
@accounts = filtered_accounts.page(params[:page])
|
2021-12-06 07:48:39 +11:00
|
|
|
@form = Form::AccountBatch.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def batch
|
2022-07-05 10:41:40 +10:00
|
|
|
authorize :account, :index?
|
|
|
|
|
2022-08-26 07:33:34 +10:00
|
|
|
@form = Form::AccountBatch.new(form_account_batch_params)
|
|
|
|
@form.current_account = current_account
|
|
|
|
@form.action = action_from_button
|
|
|
|
@form.select_all_matching = params[:select_all_matching]
|
|
|
|
@form.query = filtered_accounts
|
2021-12-06 07:48:39 +11:00
|
|
|
@form.save
|
|
|
|
rescue ActionController::ParameterMissing
|
|
|
|
flash[:alert] = I18n.t('admin.accounts.no_account_selected')
|
|
|
|
ensure
|
|
|
|
redirect_to admin_accounts_path(filter_params)
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2017-10-08 05:26:43 +11:00
|
|
|
def show
|
2017-11-12 06:23:33 +11: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 06:02:09 +11:00
|
|
|
|
2020-09-15 22:37:58 +10:00
|
|
|
@deletion_request = @account.deletion_request
|
2017-10-08 05:26:43 +11: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 06:02:09 +11:00
|
|
|
@moderation_notes = @account.targeted_moderation_notes.latest
|
2022-02-15 07:27:53 +11:00
|
|
|
@warnings = @account.strikes.includes(:target_account, :account, :appeal).latest
|
2020-09-15 22:37:58 +10:00
|
|
|
@domain_block = DomainBlock.rule_for(@account.domain)
|
2017-10-08 05:26:43 +11:00
|
|
|
end
|
2017-06-08 22:58:22 +10:00
|
|
|
|
2017-11-08 05:06:44 +11:00
|
|
|
def memorialize
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize @account, :memorialize?
|
2017-11-08 05:06:44 +11:00
|
|
|
@account.memorialize!
|
2017-11-24 12:05:53 +11:00
|
|
|
log_action :memorialize, @account
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.memorialized_msg', username: @account.acct)
|
2017-11-08 05:06:44 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize @account.user, :enable?
|
2017-11-08 05:06:44 +11:00
|
|
|
@account.user.enable!
|
2017-11-24 12:05:53 +11:00
|
|
|
log_action :enable, @account.user
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.enabled_msg', username: @account.acct)
|
2017-11-08 05:06:44 +11:00
|
|
|
end
|
|
|
|
|
2019-03-14 15:28:30 +11:00
|
|
|
def approve
|
|
|
|
authorize @account.user, :approve?
|
|
|
|
@account.user.approve!
|
2022-12-07 10:25:18 +11:00
|
|
|
log_action :approve, @account.user
|
2021-12-06 07:48:39 +11:00
|
|
|
redirect_to admin_accounts_path(status: 'pending'), notice: I18n.t('admin.accounts.approved_msg', username: @account.acct)
|
2019-03-14 15:28:30 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def reject
|
|
|
|
authorize @account.user, :reject?
|
2020-09-15 22:37:58 +10:00
|
|
|
DeleteAccountService.new.call(@account, reserve_email: false, reserve_username: false)
|
2022-12-07 10:25:18 +11:00
|
|
|
log_action :reject, @account.user
|
2021-12-06 07:48:39 +11:00
|
|
|
redirect_to admin_accounts_path(status: 'pending'), notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct)
|
2020-09-15 22:37:58 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
authorize @account, :destroy?
|
|
|
|
Admin::AccountDeletionWorker.perform_async(@account.id)
|
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.destroyed_msg', username: @account.acct)
|
2019-03-14 15:28:30 +11:00
|
|
|
end
|
|
|
|
|
2020-11-05 06:45:01 +11:00
|
|
|
def unsensitive
|
|
|
|
authorize @account, :unsensitive?
|
|
|
|
@account.unsensitize!
|
|
|
|
log_action :unsensitive, @account
|
|
|
|
redirect_to admin_account_path(@account.id)
|
|
|
|
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 06:02:09 +11:00
|
|
|
def unsilence
|
|
|
|
authorize @account, :unsilence?
|
|
|
|
@account.unsilence!
|
|
|
|
log_action :unsilence, @account
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unsilenced_msg', username: @account.acct)
|
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 06:02:09 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def unsuspend
|
|
|
|
authorize @account, :unsuspend?
|
|
|
|
@account.unsuspend!
|
2020-09-15 22:37:58 +10:00
|
|
|
Admin::UnsuspensionWorker.perform_async(@account.id)
|
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 06:02:09 +11:00
|
|
|
log_action :unsuspend, @account
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unsuspended_msg', username: @account.acct)
|
2017-11-08 05:06:44 +11:00
|
|
|
end
|
|
|
|
|
2017-06-08 22:58:22 +10:00
|
|
|
def redownload
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize @account, :redownload?
|
|
|
|
|
2018-12-28 13:38:41 +11:00
|
|
|
@account.update!(last_webfingered_at: nil)
|
|
|
|
ResolveAccountService.new.call(@account)
|
2017-06-08 22:58:22 +10:00
|
|
|
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.redownloaded_msg', username: @account.acct)
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2018-04-02 21:45:07 +10:00
|
|
|
def remove_avatar
|
|
|
|
authorize @account, :remove_avatar?
|
|
|
|
|
|
|
|
@account.avatar = nil
|
|
|
|
@account.save!
|
|
|
|
|
|
|
|
log_action :remove_avatar, @account.user
|
|
|
|
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_avatar_msg', username: @account.acct)
|
2018-04-02 21:45:07 +10:00
|
|
|
end
|
|
|
|
|
2018-12-12 05:28:03 +11:00
|
|
|
def remove_header
|
|
|
|
authorize @account, :remove_header?
|
|
|
|
|
|
|
|
@account.header = nil
|
|
|
|
@account.save!
|
|
|
|
|
|
|
|
log_action :remove_header, @account.user
|
|
|
|
|
2020-09-15 22:37:58 +10:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_header_msg', username: @account.acct)
|
2018-12-12 05:28:03 +11:00
|
|
|
end
|
|
|
|
|
2021-12-18 09:02:14 +11:00
|
|
|
def unblock_email
|
|
|
|
authorize @account, :unblock_email?
|
|
|
|
|
2024-03-21 01:38:00 +11:00
|
|
|
CanonicalEmailBlock.matching_account(@account).delete_all
|
2021-12-18 09:02:14 +11:00
|
|
|
|
|
|
|
log_action :unblock_email, @account
|
|
|
|
|
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unblocked_email_msg', username: @account.acct)
|
|
|
|
end
|
|
|
|
|
2017-04-11 05:27:03 +10:00
|
|
|
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
|
2021-12-06 07:48:39 +11:00
|
|
|
AccountFilter.new(filter_params.with_defaults(order: 'recent')).results
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2017-04-13 21:04:23 +10:00
|
|
|
def filter_params
|
2022-02-15 07:27:53 +11:00
|
|
|
params.slice(:page, *AccountFilter::KEYS).permit(:page, *AccountFilter::KEYS)
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
2021-12-06 07:48:39 +11:00
|
|
|
|
|
|
|
def form_account_batch_params
|
|
|
|
params.require(:form_account_batch).permit(:action, account_ids: [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def action_from_button
|
|
|
|
if params[:suspend]
|
|
|
|
'suspend'
|
|
|
|
elsif params[:approve]
|
|
|
|
'approve'
|
|
|
|
elsif params[:reject]
|
|
|
|
'reject'
|
|
|
|
end
|
|
|
|
end
|
2016-12-05 04:10:40 +11:00
|
|
|
end
|
2016-12-01 01:32:26 +11:00
|
|
|
end
|