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.

39 lines
892 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.media_attachments.destroy_all!
  12. @account.statuses.destroy_all!
  13. @account.stream_entries.destroy_all!
  14. @account.mentions.destroy_all!
  15. @account.notifications.destroy_all!
  16. @account.favourites.destroy_all!
  17. @account.active_relationships.destroy_all!
  18. @account.passive_relationships.destroy_all!
  19. end
  20. def purge_profile
  21. @account.suspended = true
  22. @account.display_name = ''
  23. @account.note = ''
  24. @account.avatar.destroy
  25. @account.avatar.clear
  26. @account.header.destroy
  27. @account.header.clear
  28. @account.save!
  29. end
  30. def unsubscribe_push_subscribers
  31. @account.subscriptions.destroy_all!
  32. end
  33. end