From a8ef6d24d8a05ef3edde396b3d4d242ffcbbb746 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 14 Oct 2021 21:08:37 +0200 Subject: Fix `tootctl accounts cull` not excluding domains on timeouts and certificate issues (#16433) Fixes #16410 --- lib/mastodon/accounts_cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index 050194801..16cdbd343 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -308,7 +308,7 @@ module Mastodon begin code = Request.new(:head, account.uri).perform(&:code) - rescue HTTP::ConnectionError + rescue HTTP::TimeoutError, HTTP::ConnectionError, OpenSSL::SSL::SSLError skip_domains << account.domain end -- cgit From 3f5f4273b3c2b61d71b64652f75a0d99b7a407bb Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Fri, 15 Oct 2021 04:09:56 +0900 Subject: Add optional domain restrict to tootctl accounts cull (#16511) * Add optional domain restrict to accounts cull * Use "unless" - codeclimate --- lib/mastodon/accounts_cli.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index 16cdbd343..2ef85d0a9 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -287,7 +287,7 @@ module Mastodon option :concurrency, type: :numeric, default: 5, aliases: [:c] option :dry_run, type: :boolean - desc 'cull', 'Remove remote accounts that no longer exist' + desc 'cull [DOMAIN...]', 'Remove remote accounts that no longer exist' long_desc <<-LONG_DESC Query every single remote account in the database to determine if it still exists on the origin server, and if it doesn't, @@ -296,12 +296,15 @@ module Mastodon Accounts that have had confirmed activity within the last week are excluded from the checks. LONG_DESC - def cull + def cull(*domains) skip_threshold = 7.days.ago dry_run = options[:dry_run] ? ' (DRY RUN)' : '' skip_domains = Concurrent::Set.new - processed, culled = parallelize_with_progress(Account.remote.where(protocol: :activitypub).partitioned) do |account| + query = Account.remote.where(protocol: :activitypub) + query = query.where(domain: domains) unless domains.empty? + + processed, culled = parallelize_with_progress(query.partitioned) do |account| next if account.updated_at >= skip_threshold || (account.last_webfingered_at.present? && account.last_webfingered_at >= skip_threshold) || skip_domains.include?(account.domain) code = 0 -- cgit