Skip to content

Commit

Permalink
Fix: #264 ハッシュタグをフォローしていても、非収載投稿がホームに流れない問題 (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode authored Nov 10, 2023
1 parent c6bcbb8 commit ae6fe58
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
9 changes: 5 additions & 4 deletions app/services/fan_out_on_write_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
38 changes: 37 additions & 1 deletion spec/services/fan_out_on_write_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ae6fe58

Please sign in to comment.