account_deletion_worker.rb 651 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class AccountDeletionWorker
  3. include Sidekiq::Worker
  4. sidekiq_options queue: 'pull', lock: :until_executed, lock_ttl: 1.week.to_i
  5. def perform(account_id, options = {})
  6. account = Account.find(account_id)
  7. return unless account.unavailable?
  8. reserve_username = options.with_indifferent_access.fetch(:reserve_username, true)
  9. skip_activitypub = options.with_indifferent_access.fetch(:skip_activitypub, false)
  10. DeleteAccountService.new.call(account, reserve_username: reserve_username, skip_activitypub: skip_activitypub, reserve_email: false)
  11. rescue ActiveRecord::RecordNotFound
  12. true
  13. end
  14. end