Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change tootctl domains purge to accept multiple domains at once #12046

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/mastodon/domains_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.exit_on_failure?
option :verbose, type: :boolean, aliases: [:v]
option :dry_run, type: :boolean
option :whitelist_mode, type: :boolean
desc 'purge [DOMAIN]', 'Remove accounts from a DOMAIN without a trace'
desc 'purge [DOMAIN...]', 'Remove accounts from a DOMAIN without a trace'
long_desc <<-LONG_DESC
Remove all accounts from a given DOMAIN without leaving behind any
records. Unlike a suspension, if the DOMAIN still exists in the wild,
Expand All @@ -27,16 +27,16 @@ def self.exit_on_failure?
from a single domain, all accounts from domains that are not whitelisted
are removed from the database.
LONG_DESC
def purge(domain = nil)
def purge(*domains)
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''

scope = begin
if options[:whitelist_mode]
Account.remote.where.not(domain: DomainAllow.pluck(:domain))
elsif domain.present?
Account.remote.where(domain: domain)
elsif !domains.empty?
Account.remote.where(domain: domains)
else
say('No domain given', :red)
say('No domain(s) given', :red)
exit(1)
end
end
Expand All @@ -45,11 +45,11 @@ def purge(domain = nil)
SuspendAccountService.new.call(account, reserve_username: false, skip_side_effects: true) unless options[:dry_run]
end

DomainBlock.where(domain: domain).destroy_all unless options[:dry_run]
DomainBlock.where(domain: domains).destroy_all unless options[:dry_run]

say("Removed #{processed} accounts#{dry_run}", :green)

custom_emojis = CustomEmoji.where(domain: domain)
custom_emojis = CustomEmoji.where(domain: domains)
custom_emojis_count = custom_emojis.count
custom_emojis.destroy_all unless options[:dry_run]

Expand Down