diff options
author | Ben Lubar <ben.lubar+github@gmail.com> | 2019-04-04 09:46:27 -0500 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2019-04-04 16:46:27 +0200 |
commit | e6814a332c3b355893d366cf8639ab3c7e30b52b (patch) | |
tree | 7950b5d258113046a62de1cb0b34820648637f3f | |
parent | bd365cc38bbdcfe69f333525d37f44bbbaf1d62c (diff) |
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.
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/mastodon/accounts_cli.rb | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e66c400..8670c2658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ All notable changes to this project will be documented in this file. - Change Webpack to not use @babel/preset-env to compile node_modules ([ykzts](https://github.com/tootsuite/mastodon/pull/10289)) - Change web UI to use new Web Share Target API ([gol-cha](https://github.com/tootsuite/mastodon/pull/9963)) - Change ActivityPub reports to have persistent URIs ([ThibG](https://github.com/tootsuite/mastodon/pull/10303)) +- Change `tootctl accounts cull --dry-run` to list accounts that would be deleted ([BenLubar](https://github.com/tootsuite/mastodon/pull/10460)) ### Removed @@ -75,6 +76,7 @@ All notable changes to this project will be documented in this file. - Fix race condition when streaming out deleted statuses ([ThibG](https://github.com/tootsuite/mastodon/pull/10280)) - Fix performance of admin federation UI by caching account counts ([Gargron](https://github.com/tootsuite/mastodon/pull/10374)) - Fix JS error on pages that don't define a CSRF token ([hinaloe](https://github.com/tootsuite/mastodon/pull/10383)) +- Fix `tootctl accounts cull` sometimes removing accounts that are temporarily unreachable ([BenLubar](https://github.com/tootsuite/mastodon/pull/10460)) ## [2.7.4] - 2019-03-05 ### Fixed 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 |