Use JSON.generate call for fan out service (#38222)

This commit is contained in:
Matt Jankowski
2026-03-16 10:31:58 -04:00
committed by GitHub
parent b7246518bf
commit c05492ed5a
2 changed files with 15 additions and 8 deletions

View File

@@ -171,10 +171,10 @@ class FanOutOnWriteService < BaseService
end
def anonymous_payload
@anonymous_payload ||= Oj.dump(
@anonymous_payload ||= JSON.generate({
event: update? ? :'status.update' : :update,
payload: rendered_status
)
payload: rendered_status,
}.as_json)
end
def rendered_status

View File

@@ -54,11 +54,18 @@ RSpec.describe FanOutOnWriteService do
.and be_in(home_feed_of(bob))
.and be_in(home_feed_of(tom))
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
expect(redis).to have_received(:publish).with('timeline:public', anything)
expect(redis).to have_received(:publish).with('timeline:public:local', anything)
expect(redis).to have_received(:publish).with('timeline:public:media', anything)
expected_payload = { event: 'update', payload: include(id: status.id.to_s, created_at: status.created_at.iso8601(3), content: /<p>Hello/) }
expect(redis)
.to have_received(:publish).with('timeline:hashtag:hoge', match_json_values(expected_payload))
expect(redis)
.to have_received(:publish).with('timeline:hashtag:hoge:local', match_json_values(expected_payload))
expect(redis)
.to have_received(:publish).with('timeline:public', match_json_values(expected_payload))
expect(redis)
.to have_received(:publish).with('timeline:public:local', match_json_values(expected_payload))
expect(redis)
.to have_received(:publish).with('timeline:public:media', match_json_values(expected_payload))
end
context 'with silenced_account_ids' do