about summary refs log tree commit diff
path: root/lib/mastodon
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-10-02 04:49:53 +0200
committerGitHub <noreply@github.com>2019-10-02 04:49:53 +0200
commitc7adf8082726ed3059de1c09bcc7b1cde5ca2909 (patch)
tree1c4e1a64f1909e5ebd31a2f6f5ef63b0a38957e7 /lib/mastodon
parent73bb9eb095b74572082c6dc5456c7448f32e8552 (diff)
Change `tootctl domains purge` to accept multiple domains at once (#12046)
Diffstat (limited to 'lib/mastodon')
-rw-r--r--lib/mastodon/domains_cli.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb
index 8e52de1c3..b5435bb5e 100644
--- a/lib/mastodon/domains_cli.rb
+++ b/lib/mastodon/domains_cli.rb
@@ -17,7 +17,7 @@ module Mastodon
     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,
@@ -27,16 +27,16 @@ module Mastodon
       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
@@ -45,11 +45,11 @@ module Mastodon
         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]