1
0

reject_follow_service.rb 717 B

12345678910111213141516171819202122
  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