mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-12-18 09:19:04 +01:00
6ddf0432e7
- Some associations were missing from the clean-up - Some attributes were not reset on suspension - Skip federation and streaming deletes when purging a dead domain - Move account association definitions to concern
36 lines
1 KiB
Ruby
36 lines
1 KiB
Ruby
# 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|
|
|
SuspendAccountService.new.call(account, destroy: true) unless options[:dry_run]
|
|
removed += 1
|
|
say('.', :green, false)
|
|
end
|
|
|
|
DomainBlock.where(domain: domain).destroy_all
|
|
|
|
say
|
|
say("Removed #{removed} accounts#{dry_run}", :green)
|
|
end
|
|
end
|
|
end
|