From ae6fe585018da73bf98d197e5688201364f95a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Fri, 10 Nov 2023 09:24:37 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20#264=20=E3=83=8F=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A5=E3=82=BF=E3=82=B0=E3=82=92=E3=83=95=E3=82=A9=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=81=97=E3=81=A6=E3=81=84=E3=81=A6=E3=82=82=E3=80=81?= =?UTF-8?q?=E9=9D=9E=E5=8F=8E=E8=BC=89=E6=8A=95=E7=A8=BF=E3=81=8C=E3=83=9B?= =?UTF-8?q?=E3=83=BC=E3=83=A0=E3=81=AB=E6=B5=81=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=20(#266)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/fan_out_on_write_service.rb | 9 +++-- .../services/fan_out_on_write_service_spec.rb | 38 ++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 99f3fa4bd3cf26..1455eed2ff8251 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -22,8 +22,8 @@ def call(status, options = {}) if broadcastable? fan_out_to_public_recipients! fan_out_to_public_streams! - elsif broadcastable_unlisted2? - fan_out_to_unlisted_streams! + elsif broadcastable_unlisted_public? + fan_out_to_unlisted_public_streams! end end @@ -76,8 +76,9 @@ def fan_out_to_public_streams! broadcast_to_public_streams! end - def fan_out_to_unlisted_streams! + def fan_out_to_unlisted_public_streams! broadcast_to_hashtag_streams! + deliver_to_hashtag_followers! end def deliver_to_self! @@ -201,7 +202,7 @@ def broadcastable? (@status.public_visibility? || @status.public_unlisted_visibility? || @status.login_visibility?) && !@status.reblog? && !@account.silenced? end - def broadcastable_unlisted2? + def broadcastable_unlisted_public? @status.unlisted_visibility? && @status.compute_searchability == 'public' && !@status.reblog? && !@account.silenced? end end diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 9bcc67292f4ebc..d7393a7e5e7b69 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -17,6 +17,7 @@ let!(:bob) { Fabricate(:user, current_sign_in_at: last_active_at, account_attributes: { username: 'bob' }).account } let!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account } let!(:ohagi) { Fabricate(:user, current_sign_in_at: last_active_at).account } + let!(:tagf) { Fabricate(:user, current_sign_in_at: last_active_at).account } let!(:list) { nil } let!(:empty_list) { nil } @@ -37,6 +38,9 @@ allow(redis).to receive(:publish) + tag = status.tags.first + Fabricate(:tag_follow, account: tagf, tag: tag) if tag.present? + subject.call(status) unless custom_before end @@ -87,6 +91,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to include status.id end + it 'is added to the tag follower' do + expect(home_feed_of(tagf)).to include status.id + end + it 'is broadcast to the hashtag stream' do expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything) @@ -265,6 +273,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to_not include status.id end + it 'is not added to the tag follower' do + expect(home_feed_of(tagf)).to_not include status.id + end + it 'is not broadcast publicly' do expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to_not have_received(:publish).with('timeline:public', anything) @@ -321,6 +333,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to include status.id end + it 'is not added to the tag follower' do + expect(home_feed_of(tagf)).to_not include status.id + end + it 'is not broadcast publicly' do expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to_not have_received(:publish).with('timeline:public', anything) @@ -394,6 +410,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to include status.id end + it 'is added to the tag follower' do + expect(home_feed_of(tagf)).to include status.id + end + it 'is broadcast publicly' do expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to have_received(:publish).with('timeline:public:local', anything) @@ -509,6 +529,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to include status.id end + it 'is added to the tag follower' do + expect(home_feed_of(tagf)).to include status.id + end + it 'is not broadcast publicly' do expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to_not have_received(:publish).with('timeline:public', anything) @@ -517,10 +541,14 @@ def antenna_with_options(owner, **options) context 'with searchability public_unlisted' do let(:searchability) { 'public_unlisted' } - it 'is not broadcast to the hashtag stream' do + it 'is broadcast to the hashtag stream' do expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything) end + + it 'is added to the tag follower' do + expect(home_feed_of(tagf)).to include status.id + end end context 'with searchability private' do @@ -530,6 +558,10 @@ def antenna_with_options(owner, **options) expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything) end + + it 'is not added to the tag follower' do + expect(home_feed_of(tagf)).to_not include status.id + end end context 'when local timeline is disabled' do @@ -621,6 +653,10 @@ def antenna_with_options(owner, **options) expect(home_feed_of(tom)).to_not include status.id end + it 'is not added to the tag follower' do + expect(home_feed_of(tagf)).to_not include status.id + end + it 'is not broadcast publicly' do expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge', anything) expect(redis).to_not have_received(:publish).with('timeline:public', anything)