闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

  1. # frozen_string_literal: true
  2. require_relative '../../config/boot'
  3. require_relative '../../config/environment'
  4. require_relative 'cli_helper'
  5. module Mastodon
  6. class DomainsCLI < Thor
  7. def self.exit_on_failure?
  8. true
  9. end
  10. option :dry_run, type: :boolean
  11. desc 'purge DOMAIN', 'Remove accounts from a DOMAIN without a trace'
  12. long_desc <<-LONG_DESC
  13. Remove all accounts from a given DOMAIN without leaving behind any
  14. records. Unlike a suspension, if the DOMAIN still exists in the wild,
  15. it means the accounts could return if they are resolved again.
  16. LONG_DESC
  17. def purge(domain)
  18. removed = 0
  19. dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
  20. Account.where(domain: domain).find_each do |account|
  21. SuspendAccountService.new.call(account, destroy: true) unless options[:dry_run]
  22. removed += 1
  23. say('.', :green, false)
  24. end
  25. DomainBlock.where(domain: domain).destroy_all
  26. say
  27. say("Removed #{removed} accounts#{dry_run}", :green)
  28. end
  29. end
  30. end