forked from fedi/mastodon
parent
8569126c2e
commit
2e0eac71dd
|
@ -17,6 +17,7 @@ module Mastodon
|
||||||
option :verbose, type: :boolean, aliases: [:v]
|
option :verbose, type: :boolean, aliases: [:v]
|
||||||
option :dry_run, type: :boolean
|
option :dry_run, type: :boolean
|
||||||
option :limited_federation_mode, type: :boolean
|
option :limited_federation_mode, type: :boolean
|
||||||
|
option :by_uri, type: :boolean
|
||||||
desc 'purge [DOMAIN...]', 'Remove accounts from a DOMAIN without a trace'
|
desc 'purge [DOMAIN...]', 'Remove accounts from a DOMAIN without a trace'
|
||||||
long_desc <<-LONG_DESC
|
long_desc <<-LONG_DESC
|
||||||
Remove all accounts from a given DOMAIN without leaving behind any
|
Remove all accounts from a given DOMAIN without leaving behind any
|
||||||
|
@ -26,6 +27,12 @@ module Mastodon
|
||||||
When the --limited-federation-mode option is given, instead of purging accounts
|
When the --limited-federation-mode option is given, instead of purging accounts
|
||||||
from a single domain, all accounts from domains that have not been explicitly allowed
|
from a single domain, all accounts from domains that have not been explicitly allowed
|
||||||
are removed from the database.
|
are removed from the database.
|
||||||
|
|
||||||
|
When the --by-uri option is given, DOMAIN is used to match the domain part of actor
|
||||||
|
URIs rather than the domain part of the webfinger handle. For instance, an account
|
||||||
|
that has the handle `foo@bar.com` but whose profile is at the URL
|
||||||
|
`https://mastodon-bar.com/users/foo`, would be purged by either
|
||||||
|
`tootctl domains purge bar.com` or `tootctl domains purge --by-uri mastodon-bar.com`.
|
||||||
LONG_DESC
|
LONG_DESC
|
||||||
def purge(*domains)
|
def purge(*domains)
|
||||||
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
|
dry_run = options[:dry_run] ? ' (DRY RUN)' : ''
|
||||||
|
@ -34,7 +41,11 @@ module Mastodon
|
||||||
if options[:limited_federation_mode]
|
if options[:limited_federation_mode]
|
||||||
Account.remote.where.not(domain: DomainAllow.pluck(:domain))
|
Account.remote.where.not(domain: DomainAllow.pluck(:domain))
|
||||||
elsif !domains.empty?
|
elsif !domains.empty?
|
||||||
|
if options[:by_uri]
|
||||||
|
domains.map { |domain| Account.remote.where(Account.arel_table[:uri].matches("https://#{domain}/%", false, true)) }.reduce(:or)
|
||||||
|
else
|
||||||
Account.remote.where(domain: domains)
|
Account.remote.where(domain: domains)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
say('No domain(s) given', :red)
|
say('No domain(s) given', :red)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
Loading…
Reference in a new issue