mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
Add --suspended-only option to tootctl emoji purge (#37828)
This commit is contained in:
@@ -109,15 +109,27 @@ module Mastodon::CLI
|
||||
end
|
||||
|
||||
option :remote_only, type: :boolean
|
||||
option :suspended_only, type: :boolean
|
||||
desc 'purge', 'Remove all custom emoji'
|
||||
long_desc <<-LONG_DESC
|
||||
Removes all custom emoji.
|
||||
|
||||
With the --remote-only option, only remote emoji will be deleted.
|
||||
|
||||
With the --suspended-only option, only emoji from suspended servers will be deleted.
|
||||
LONG_DESC
|
||||
def purge
|
||||
scope = options[:remote_only] ? CustomEmoji.remote : CustomEmoji
|
||||
scope.in_batches.destroy_all
|
||||
if options[:suspended_only]
|
||||
DomainBlock.where(severity: :suspend).find_each do |domain_block|
|
||||
CustomEmoji.by_domain_and_subdomains(domain_block.domain).find_in_batches do |custom_emojis|
|
||||
AttachmentBatch.new(CustomEmoji, custom_emojis).delete
|
||||
end
|
||||
end
|
||||
else
|
||||
scope = options[:remote_only] ? CustomEmoji.remote : CustomEmoji
|
||||
scope.in_batches.destroy_all
|
||||
end
|
||||
|
||||
say('OK', :green)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user