1
0

remove_from_followers_service.rb 695 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class RemoveFromFollowersService < BaseService
  3. include Payloadable
  4. def call(source_account, target_accounts)
  5. source_account.passive_relationships.where(account_id: target_accounts).find_each do |follow|
  6. follow.destroy
  7. if source_account.local? && !follow.account.local? && follow.account.activitypub?
  8. create_notification(follow)
  9. end
  10. end
  11. end
  12. private
  13. def create_notification(follow)
  14. ActivityPub::DeliveryWorker.perform_async(build_json(follow), follow.target_account_id, follow.account.inbox_url)
  15. end
  16. def build_json(follow)
  17. Oj.dump(serialize_payload(follow, ActivityPub::RejectFollowSerializer))
  18. end
  19. end