move_service.rb 735 B

1234567891011121314151617181920212223242526272829303132
  1. # frozen_string_literal: true
  2. class MoveService < BaseService
  3. def call(migration)
  4. @migration = migration
  5. @source_account = migration.account
  6. @target_account = migration.target_account
  7. update_redirect!
  8. process_local_relationships!
  9. distribute_update!
  10. distribute_move!
  11. end
  12. private
  13. def update_redirect!
  14. @source_account.update!(moved_to_account: @target_account)
  15. end
  16. def process_local_relationships!
  17. MoveWorker.perform_async(@source_account.id, @target_account.id)
  18. end
  19. def distribute_update!
  20. ActivityPub::UpdateDistributionWorker.perform_async(@source_account.id)
  21. end
  22. def distribute_move!
  23. ActivityPub::MoveDistributionWorker.perform_async(@migration.id)
  24. end
  25. end