22
33module Admin
44 class AccountsController < BaseController
5- before_action :set_account , only : [ :show , :redownload , :remove_avatar , :remove_header , :enable , :unsilence , :unsuspend , :memorialize , :approve , :reject ]
5+ before_action :set_account , except : [ :index ]
66 before_action :require_remote_account! , only : [ :redownload ]
77 before_action :require_local_account! , only : [ :enable , :memorialize , :approve , :reject ]
88
@@ -14,49 +14,58 @@ def index
1414 def show
1515 authorize @account , :show?
1616
17+ @deletion_request = @account . deletion_request
1718 @account_moderation_note = current_account . account_moderation_notes . new ( target_account : @account )
1819 @moderation_notes = @account . targeted_moderation_notes . latest
1920 @warnings = @account . targeted_account_warnings . latest . custom
21+ @domain_block = DomainBlock . rule_for ( @account . domain )
2022 end
2123
2224 def memorialize
2325 authorize @account , :memorialize?
2426 @account . memorialize!
2527 log_action :memorialize , @account
26- redirect_to admin_account_path ( @account . id )
28+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.memorialized_msg' , username : @account . acct )
2729 end
2830
2931 def enable
3032 authorize @account . user , :enable?
3133 @account . user . enable!
3234 log_action :enable , @account . user
33- redirect_to admin_account_path ( @account . id )
35+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.enabled_msg' , username : @account . acct )
3436 end
3537
3638 def approve
3739 authorize @account . user , :approve?
3840 @account . user . approve!
39- redirect_to admin_pending_accounts_path
41+ redirect_to admin_pending_accounts_path , notice : I18n . t ( 'admin.accounts.approved_msg' , username : @account . acct )
4042 end
4143
4244 def reject
4345 authorize @account . user , :reject?
44- SuspendAccountService . new . call ( @account , reserve_email : false , reserve_username : false )
45- redirect_to admin_pending_accounts_path
46+ DeleteAccountService . new . call ( @account , reserve_email : false , reserve_username : false )
47+ redirect_to admin_pending_accounts_path , notice : I18n . t ( 'admin.accounts.rejected_msg' , username : @account . acct )
48+ end
49+
50+ def destroy
51+ authorize @account , :destroy?
52+ Admin ::AccountDeletionWorker . perform_async ( @account . id )
53+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.destroyed_msg' , username : @account . acct )
4654 end
4755
4856 def unsilence
4957 authorize @account , :unsilence?
5058 @account . unsilence!
5159 log_action :unsilence , @account
52- redirect_to admin_account_path ( @account . id )
60+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.unsilenced_msg' , username : @account . acct )
5361 end
5462
5563 def unsuspend
5664 authorize @account , :unsuspend?
5765 @account . unsuspend!
66+ Admin ::UnsuspensionWorker . perform_async ( @account . id )
5867 log_action :unsuspend , @account
59- redirect_to admin_account_path ( @account . id )
68+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.unsuspended_msg' , username : @account . acct )
6069 end
6170
6271 def redownload
@@ -65,7 +74,7 @@ def redownload
6574 @account . update! ( last_webfingered_at : nil )
6675 ResolveAccountService . new . call ( @account )
6776
68- redirect_to admin_account_path ( @account . id )
77+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.redownloaded_msg' , username : @account . acct )
6978 end
7079
7180 def remove_avatar
@@ -76,7 +85,7 @@ def remove_avatar
7685
7786 log_action :remove_avatar , @account . user
7887
79- redirect_to admin_account_path ( @account . id )
88+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.removed_avatar_msg' , username : @account . acct )
8089 end
8190
8291 def remove_header
@@ -87,7 +96,7 @@ def remove_header
8796
8897 log_action :remove_header , @account . user
8998
90- redirect_to admin_account_path ( @account . id )
99+ redirect_to admin_account_path ( @account . id ) , notice : I18n . t ( 'admin.accounts.removed_header_msg' , username : @account . acct )
91100 end
92101
93102 private
0 commit comments