about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2018-10-22 05:52:27 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-10-21 22:52:27 +0200
commit2e18ad74dcffb2e1aeec9f265becd3308c110a67 (patch)
treee37fea5ed58828cc59edb16931066e2acacf897e /lib
parent84cf78da8ad80d8a4128451d8d96ae74acbac318 (diff)
Fix tootctl cull on dead servers (#9041)
* Delete first 9 accounts on dead servers

* Clean up code by moving dead server culling to the end
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/accounts_cli.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb
index 704cf474b..829fab19e 100644
--- a/lib/mastodon/accounts_cli.rb
+++ b/lib/mastodon/accounts_cli.rb
@@ -239,7 +239,7 @@ module Mastodon
           end
         end
 
-        if [404, 410].include?(code) || dead_servers.include?(account.domain)
+        if [404, 410].include?(code)
           unless options[:dry_run]
             SuspendAccountService.new.call(account)
             account.destroy
@@ -252,6 +252,18 @@ module Mastodon
         end
       end
 
+      # Remove dead servers
+      unless dead_servers.empty? || options[:dry_run]
+        dead_servers.each do |domain|
+          Account.where(domain: domain).find_each do |account|
+            SuspendAccountService.new.call(account)
+            account.destroy
+            culled += 1
+            say('.', :green, false)
+          end
+        end
+      end
+
       say
       say("Removed #{culled} accounts (#{dead_servers.size} dead servers)#{dry_run}", :green)