mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-12-22 05:08:03 +00:00
Add --email and --dry-run options to tootctl accounts delete
(#22328)
This commit is contained in:
parent
5917b46c05
commit
f239d31f23
|
@ -200,21 +200,44 @@ module Mastodon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'delete USERNAME', 'Delete a user'
|
option :email
|
||||||
|
option :dry_run, type: :boolean
|
||||||
|
desc 'delete [USERNAME]', 'Delete a user'
|
||||||
long_desc <<-LONG_DESC
|
long_desc <<-LONG_DESC
|
||||||
Remove a user account with a given USERNAME.
|
Remove a user account with a given USERNAME.
|
||||||
LONG_DESC
|
|
||||||
def delete(username)
|
|
||||||
account = Account.find_local(username)
|
|
||||||
|
|
||||||
if account.nil?
|
With the --email option, the user is selected based on email
|
||||||
say('No user with such username', :red)
|
rather than username.
|
||||||
|
LONG_DESC
|
||||||
|
def delete(username = nil)
|
||||||
|
if username.present? && options[:email].present?
|
||||||
|
say('Use username or --email, not both', :red)
|
||||||
|
exit(1)
|
||||||
|
elsif username.blank? && options[:email].blank?
|
||||||
|
say('No username provided', :red)
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
say("Deleting user with #{account.statuses_count} statuses, this might take a while...")
|
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
|
||||||
DeleteAccountService.new.call(account, reserve_email: false)
|
account = nil
|
||||||
say('OK', :green)
|
|
||||||
|
if username.present?
|
||||||
|
account = Account.find_local(username)
|
||||||
|
if account.nil?
|
||||||
|
say('No user with such username', :red)
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
account = Account.left_joins(:user).find_by(user: { email: options[:email] })
|
||||||
|
if account.nil?
|
||||||
|
say('No user with such email', :red)
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
say("Deleting user with #{account.statuses_count} statuses, this might take a while...#{dry_run}")
|
||||||
|
DeleteAccountService.new.call(account, reserve_email: false) unless options[:dry_run]
|
||||||
|
say("OK#{dry_run}", :green)
|
||||||
end
|
end
|
||||||
|
|
||||||
option :force, type: :boolean, aliases: [:f], description: 'Override public key check'
|
option :force, type: :boolean, aliases: [:f], description: 'Override public key check'
|
||||||
|
|
Loading…
Reference in a new issue