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
This commit is contained in:
Jeong Arm 2018-10-22 05:52:27 +09:00 committed by Eugen Rochko
parent 84cf78da8a
commit 2e18ad74dc
1 changed files with 13 additions and 1 deletions

View File

@ -239,7 +239,7 @@ module Mastodon
end end
end end
if [404, 410].include?(code) || dead_servers.include?(account.domain) if [404, 410].include?(code)
unless options[:dry_run] unless options[:dry_run]
SuspendAccountService.new.call(account) SuspendAccountService.new.call(account)
account.destroy account.destroy
@ -252,6 +252,18 @@ module Mastodon
end end
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
say("Removed #{culled} accounts (#{dead_servers.size} dead servers)#{dry_run}", :green) say("Removed #{culled} accounts (#{dead_servers.size} dead servers)#{dry_run}", :green)