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.

22 lines
717 B

  1. # frozen_string_literal: true
  2. class RejectFollowService < BaseService
  3. include Payloadable
  4. def call(source_account, target_account)
  5. follow_request = FollowRequest.find_by!(account: source_account, target_account: target_account)
  6. follow_request.reject!
  7. create_notification(follow_request) if !source_account.local? && source_account.activitypub?
  8. follow_request
  9. end
  10. private
  11. def create_notification(follow_request)
  12. ActivityPub::DeliveryWorker.perform_async(build_json(follow_request), follow_request.target_account_id, follow_request.account.inbox_url)
  13. end
  14. def build_json(follow_request)
  15. Oj.dump(serialize_payload(follow_request, ActivityPub::RejectFollowSerializer))
  16. end
  17. end