diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 99f3fa4bd3..1455eed2ff 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -22,8 +22,8 @@ class FanOutOnWriteService < BaseService 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 @@ class FanOutOnWriteService < BaseService 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 @@ class FanOutOnWriteService < BaseService (@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 9bcc67292f..d7393a7e5e 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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 @@ RSpec.describe FanOutOnWriteService, type: :service do 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)