Use to_json call for AP::Follow reject path (#38227)

This commit is contained in:
Matt Jankowski
2026-03-16 10:40:51 -04:00
committed by GitHub
parent 8ed13bc6f7
commit 70230c632c
2 changed files with 18 additions and 1 deletions

View File

@@ -39,7 +39,7 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
end
def reject_follow_request!(target_account)
json = Oj.dump(serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer))
json = serialize_payload(FollowRequest.new(account: @account, target_account: target_account, uri: @json['id']), ActivityPub::RejectFollowSerializer).to_json
ActivityPub::DeliveryWorker.perform_async(json, target_account.id, @account.inbox_url)
end
end

View File

@@ -84,6 +84,23 @@ RSpec.describe ActivityPub::Activity::Follow do
end
end
context 'when recipient blocks sender' do
before { Fabricate :block, account: recipient, target_account: sender }
it 'sends a reject and does not follow' do
subject.perform
expect(sender.requested?(recipient))
.to be false
expect(ActivityPub::DeliveryWorker)
.to have_enqueued_sidekiq_job(
match_json_values(type: 'Reject', object: include(type: 'Follow')),
recipient.id,
anything
)
end
end
context 'when a follow relationship already exists' do
before do
sender.active_relationships.create!(target_account: recipient, uri: 'bar')