1
0

purge_domain_service.rb 701 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. class PurgeDomainService < BaseService
  3. def call(domain)
  4. @domain = domain
  5. purge_relationship_severance_events!
  6. purge_accounts!
  7. purge_emojis!
  8. Instance.refresh
  9. end
  10. def purge_relationship_severance_events!
  11. RelationshipSeveranceEvent.where(type: [:domain_block, :user_domain_block], target_name: @domain).in_batches.update_all(purged: true)
  12. end
  13. def purge_accounts!
  14. Account.remote.where(domain: @domain).find_each do |account|
  15. DeleteAccountService.new.call(account, reserve_username: false, skip_side_effects: true)
  16. end
  17. end
  18. def purge_emojis!
  19. CustomEmoji.remote.where(domain: @domain).find_each(&:destroy)
  20. end
  21. end