]> cat aescling's git repositories - mastodon.git/commitdiff
Fix tootctl cull on dead servers (#9041)
authorJeong Arm <kjwonmail@gmail.com>
Sun, 21 Oct 2018 20:52:27 +0000 (05:52 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 21 Oct 2018 20:52:27 +0000 (22:52 +0200)
* Delete first 9 accounts on dead servers

* Clean up code by moving dead server culling to the end

lib/mastodon/accounts_cli.rb

index 704cf474b50bc523a91bb7104723d78c2c011466..829fab19ebfed9fd5737872816e684b6f64b2b8c 100644 (file)
@@ -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)