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.

41 lines
911 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.notifications.destroy_all
  17. @account.favourites.destroy_all
  18. @account.active_relationships.destroy_all
  19. @account.passive_relationships.destroy_all
  20. end
  21. def purge_profile
  22. @account.suspended = true
  23. @account.display_name = ''
  24. @account.note = ''
  25. @account.avatar.destroy
  26. @account.avatar.clear
  27. @account.header.destroy
  28. @account.header.clear
  29. @account.save!
  30. end
  31. def unsubscribe_push_subscribers
  32. @account.subscriptions.destroy_all
  33. end
  34. end