From e6814a332c3b355893d366cf8639ab3c7e30b52b Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Thu, 4 Apr 2019 09:46:27 -0500 Subject: Fix `tootctl accounts cull` (#10460) * List the actual accounts that would have been culled during a dry run. Otherwise, the dry run mode is basically useless. * Prevent unreachable domains from inheriting the previous status code. * Update CHANGELOG.md for #10460. --- lib/mastodon/accounts_cli.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index f02b2149b..41e902e8f 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -219,12 +219,14 @@ module Mastodon def cull skip_threshold = 7.days.ago culled = 0 + dry_run_culled = [] skip_domains = Set.new dry_run = options[:dry_run] ? ' (DRY RUN)' : '' Account.remote.where(protocol: :activitypub).partitioned.find_each do |account| next if account.updated_at >= skip_threshold || (account.last_webfingered_at.present? && account.last_webfingered_at >= skip_threshold) + code = 0 unless skip_domains.include?(account.domain) begin code = Request.new(:head, account.uri).perform(&:code) @@ -236,7 +238,11 @@ module Mastodon end if [404, 410].include?(code) - SuspendAccountService.new.call(account, destroy: true) unless options[:dry_run] + if options[:dry_run] + dry_run_culled << account.acct + else + SuspendAccountService.new.call(account, destroy: true) + end culled += 1 say('+', :green, false) else @@ -252,6 +258,11 @@ module Mastodon say('The following servers were not available during the check:', :yellow) skip_domains.each { |domain| say(' ' + domain) } end + + unless dry_run_culled.empty? + say('The following accounts would have been deleted:', :green) + dry_run_culled.each { |account| say(' ' + account) } + end end option :all, type: :boolean -- cgit