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.

23 lines
705 B

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