2016-11-30 16:32:26 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
module Admin
|
|
|
|
class AccountsController < BaseController
|
2020-09-15 15:37:58 +03:00
|
|
|
before_action :set_account, except: [:index]
|
2019-07-07 00:26:16 +03:00
|
|
|
before_action :require_remote_account!, only: [:redownload]
|
2019-03-14 06:28:30 +02:00
|
|
|
before_action :require_local_account!, only: [:enable, :memorialize, :approve, :reject]
|
2017-06-08 15:58:22 +03:00
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
def index
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize :account, :index?
|
2017-04-13 14:04:23 +03:00
|
|
|
@accounts = filtered_accounts.page(params[:page])
|
2017-04-10 22:27:03 +03:00
|
|
|
end
|
|
|
|
|
2017-10-07 21:26:43 +03:00
|
|
|
def show
|
2017-11-11 21:23:33 +02: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-22 21:02:09 +02:00
|
|
|
|
2020-09-15 15:37:58 +03:00
|
|
|
@deletion_request = @account.deletion_request
|
2017-10-07 21:26:43 +03: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-22 21:02:09 +02:00
|
|
|
@moderation_notes = @account.targeted_moderation_notes.latest
|
|
|
|
@warnings = @account.targeted_account_warnings.latest.custom
|
2020-09-15 15:37:58 +03:00
|
|
|
@domain_block = DomainBlock.rule_for(@account.domain)
|
2017-10-07 21:26:43 +03:00
|
|
|
end
|
2017-06-08 15:58:22 +03:00
|
|
|
|
2017-11-07 20:06:44 +02:00
|
|
|
def memorialize
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize @account, :memorialize?
|
2017-11-07 20:06:44 +02:00
|
|
|
@account.memorialize!
|
2017-11-24 03:05:53 +02:00
|
|
|
log_action :memorialize, @account
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.memorialized_msg', username: @account.acct)
|
2017-11-07 20:06:44 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize @account.user, :enable?
|
2017-11-07 20:06:44 +02:00
|
|
|
@account.user.enable!
|
2017-11-24 03:05:53 +02:00
|
|
|
log_action :enable, @account.user
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.enabled_msg', username: @account.acct)
|
2017-11-07 20:06:44 +02:00
|
|
|
end
|
|
|
|
|
2019-03-14 06:28:30 +02:00
|
|
|
def approve
|
|
|
|
authorize @account.user, :approve?
|
|
|
|
@account.user.approve!
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_pending_accounts_path, notice: I18n.t('admin.accounts.approved_msg', username: @account.acct)
|
2019-03-14 06:28:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def reject
|
|
|
|
authorize @account.user, :reject?
|
2020-09-15 15:37:58 +03:00
|
|
|
DeleteAccountService.new.call(@account, reserve_email: false, reserve_username: false)
|
|
|
|
redirect_to admin_pending_accounts_path, notice: I18n.t('admin.accounts.rejected_msg', username: @account.acct)
|
|
|
|
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 06:28:30 +02:00
|
|
|
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-22 21:02:09 +02:00
|
|
|
def unsilence
|
|
|
|
authorize @account, :unsilence?
|
|
|
|
@account.unsilence!
|
|
|
|
log_action :unsilence, @account
|
2020-09-15 15:37:58 +03: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-22 21:02:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def unsuspend
|
|
|
|
authorize @account, :unsuspend?
|
|
|
|
@account.unsuspend!
|
2020-09-15 15:37:58 +03: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-22 21:02:09 +02:00
|
|
|
log_action :unsuspend, @account
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.unsuspended_msg', username: @account.acct)
|
2017-11-07 20:06:44 +02:00
|
|
|
end
|
|
|
|
|
2017-06-08 15:58:22 +03:00
|
|
|
def redownload
|
2017-11-11 21:23:33 +02:00
|
|
|
authorize @account, :redownload?
|
|
|
|
|
2018-12-28 04:38:41 +02:00
|
|
|
@account.update!(last_webfingered_at: nil)
|
|
|
|
ResolveAccountService.new.call(@account)
|
2017-06-08 15:58:22 +03:00
|
|
|
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.redownloaded_msg', username: @account.acct)
|
2017-04-10 22:27:03 +03:00
|
|
|
end
|
|
|
|
|
2018-04-02 14:45:07 +03:00
|
|
|
def remove_avatar
|
|
|
|
authorize @account, :remove_avatar?
|
|
|
|
|
|
|
|
@account.avatar = nil
|
|
|
|
@account.save!
|
|
|
|
|
|
|
|
log_action :remove_avatar, @account.user
|
|
|
|
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_avatar_msg', username: @account.acct)
|
2018-04-02 14:45:07 +03:00
|
|
|
end
|
|
|
|
|
2018-12-11 20:28:03 +02:00
|
|
|
def remove_header
|
|
|
|
authorize @account, :remove_header?
|
|
|
|
|
|
|
|
@account.header = nil
|
|
|
|
@account.save!
|
|
|
|
|
|
|
|
log_action :remove_header, @account.user
|
|
|
|
|
2020-09-15 15:37:58 +03:00
|
|
|
redirect_to admin_account_path(@account.id), notice: I18n.t('admin.accounts.removed_header_msg', username: @account.acct)
|
2018-12-11 20:28:03 +02:00
|
|
|
end
|
|
|
|
|
2017-04-10 22:27:03 +03:00
|
|
|
private
|
|
|
|
|
2017-06-08 15:58:22 +03: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 20:06:44 +02:00
|
|
|
def require_local_account!
|
|
|
|
redirect_to admin_account_path(@account.id) unless @account.local? && @account.user.present?
|
|
|
|
end
|
|
|
|
|
2017-04-13 14:04:23 +03:00
|
|
|
def filtered_accounts
|
|
|
|
AccountFilter.new(filter_params).results
|
2017-04-10 22:27:03 +03:00
|
|
|
end
|
|
|
|
|
2017-04-13 14:04:23 +03:00
|
|
|
def filter_params
|
2020-01-20 16:55:03 +02:00
|
|
|
params.slice(*AccountFilter::KEYS).permit(*AccountFilter::KEYS)
|
2017-04-10 22:27:03 +03:00
|
|
|
end
|
2016-12-04 19:10:40 +02:00
|
|
|
end
|
2016-11-30 16:32:26 +02:00
|
|
|
end
|