You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
945 B

  1. # frozen_string_literal: true
  2. class SuspendAccountService < BaseService
  3. def call(account)
  4. @account = account
  5. purge_content
  6. purge_profile
  7. unsubscribe_push_subscribers
  8. end
  9. private
  10. def purge_content
  11. @account.statuses.find_each do |status|
  12. RemoveStatusService.new.call(status)
  13. end
  14. @account.media_attachments.destroy_all
  15. @account.stream_entries.destroy_all
  16. @account.mentions.destroy_all
  17. @account.notifications.destroy_all
  18. @account.favourites.destroy_all
  19. @account.active_relationships.destroy_all
  20. @account.passive_relationships.destroy_all
  21. end
  22. def purge_profile
  23. @account.suspended = true
  24. @account.display_name = ''
  25. @account.note = ''
  26. @account.avatar.destroy
  27. @account.avatar.clear
  28. @account.header.destroy
  29. @account.header.clear
  30. @account.save!
  31. end
  32. def unsubscribe_push_subscribers
  33. @account.subscriptions.destroy_all
  34. end
  35. end