diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-10-27 22:56:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-27 22:56:16 +0200 |
commit | 6f78500d4f515c65ec66416e2d78bc9ae247f91c (patch) | |
tree | 2d7f8125f6190868f9a85f37b951d4a828c93c5e /lib/mastodon/domains_cli.rb | |
parent | a90b569350853b648610814a06f1e9c8a930e16a (diff) |
Do not remove "dead" domains in tootctl accounts cull (#9108)
Leave `tootctl accounts cull` to simply check removed accounts from live domains, and skip temporarily unavailable domains, while listing them in the final output for further action. Add `tootctl domains purge DOMAIN` to be able to purge a domain from that list manually
Diffstat (limited to 'lib/mastodon/domains_cli.rb')
-rw-r--r-- | lib/mastodon/domains_cli.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb new file mode 100644 index 000000000..a7a5caa11 --- /dev/null +++ b/lib/mastodon/domains_cli.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +require_relative '../../config/boot' +require_relative '../../config/environment' +require_relative 'cli_helper' + +module Mastodon + class DomainsCLI < Thor + def self.exit_on_failure? + true + end + + option :dry_run, type: :boolean + desc 'purge DOMAIN', 'Remove accounts from a DOMAIN without a trace' + long_desc <<-LONG_DESC + Remove all accounts from a given DOMAIN without leaving behind any + records. Unlike a suspension, if the DOMAIN still exists in the wild, + it means the accounts could return if they are resolved again. + LONG_DESC + def purge(domain) + removed = 0 + dry_run = options[:dry_run] ? ' (DRY RUN)' : '' + + Account.where(domain: domain).find_each do |account| + unless options[:dry_run] + SuspendAccountService.new.call(account) + account.destroy + end + + removed += 1 + say('.', :green, false) + end + + DomainBlock.where(domain: domain).destroy_all + + say + say("Removed #{removed} accounts#{dry_run}", :green) + end + end +end |