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.

40 lines
929 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.reorder(nil).find_each do |status|
  12. # This federates out deletes to previous followers
  13. RemoveStatusService.new.call(status)
  14. end
  15. @account.media_attachments.destroy_all
  16. @account.stream_entries.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.header.destroy
  28. @account.save!
  29. end
  30. def unsubscribe_push_subscribers
  31. @account.subscriptions.destroy_all
  32. end
  33. end