parent
c6bcbb837f
commit
ae6fe58501
2 changed files with 42 additions and 5 deletions
|
@ -22,8 +22,8 @@ class FanOutOnWriteService < BaseService
|
||||||
if broadcastable?
|
if broadcastable?
|
||||||
fan_out_to_public_recipients!
|
fan_out_to_public_recipients!
|
||||||
fan_out_to_public_streams!
|
fan_out_to_public_streams!
|
||||||
elsif broadcastable_unlisted2?
|
elsif broadcastable_unlisted_public?
|
||||||
fan_out_to_unlisted_streams!
|
fan_out_to_unlisted_public_streams!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -76,8 +76,9 @@ class FanOutOnWriteService < BaseService
|
||||||
broadcast_to_public_streams!
|
broadcast_to_public_streams!
|
||||||
end
|
end
|
||||||
|
|
||||||
def fan_out_to_unlisted_streams!
|
def fan_out_to_unlisted_public_streams!
|
||||||
broadcast_to_hashtag_streams!
|
broadcast_to_hashtag_streams!
|
||||||
|
deliver_to_hashtag_followers!
|
||||||
end
|
end
|
||||||
|
|
||||||
def deliver_to_self!
|
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?
|
(@status.public_visibility? || @status.public_unlisted_visibility? || @status.login_visibility?) && !@status.reblog? && !@account.silenced?
|
||||||
end
|
end
|
||||||
|
|
||||||
def broadcastable_unlisted2?
|
def broadcastable_unlisted_public?
|
||||||
@status.unlisted_visibility? && @status.compute_searchability == 'public' && !@status.reblog? && !@account.silenced?
|
@status.unlisted_visibility? && @status.compute_searchability == 'public' && !@status.reblog? && !@account.silenced?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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!(: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!(:tom) { Fabricate(:user, current_sign_in_at: last_active_at).account }
|
||||||
let!(:ohagi) { 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!(:list) { nil }
|
||||||
let!(:empty_list) { nil }
|
let!(:empty_list) { nil }
|
||||||
|
@ -37,6 +38,9 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
|
|
||||||
allow(redis).to receive(:publish)
|
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
|
subject.call(status) unless custom_before
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -87,6 +91,10 @@ RSpec.describe FanOutOnWriteService, type: :service do
|
||||||
expect(home_feed_of(tom)).to include status.id
|
expect(home_feed_of(tom)).to include status.id
|
||||||
end
|
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
|
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', anything)
|
||||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', 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
|
expect(home_feed_of(tom)).to_not include status.id
|
||||||
end
|
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
|
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:hashtag:hoge', anything)
|
||||||
expect(redis).to_not have_received(:publish).with('timeline:public', 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
|
expect(home_feed_of(tom)).to include status.id
|
||||||
end
|
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
|
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:hashtag:hoge', anything)
|
||||||
expect(redis).to_not have_received(:publish).with('timeline:public', 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
|
expect(home_feed_of(tom)).to include status.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is added to the tag follower' do
|
||||||
|
expect(home_feed_of(tagf)).to include status.id
|
||||||
|
end
|
||||||
|
|
||||||
it 'is broadcast publicly' do
|
it 'is broadcast publicly' do
|
||||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||||
expect(redis).to have_received(:publish).with('timeline:public:local', 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
|
expect(home_feed_of(tom)).to include status.id
|
||||||
end
|
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
|
it 'is not broadcast publicly' do
|
||||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge', anything)
|
||||||
expect(redis).to_not have_received(:publish).with('timeline:public', 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
|
context 'with searchability public_unlisted' do
|
||||||
let(:searchability) { 'public_unlisted' }
|
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', anything)
|
||||||
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
expect(redis).to have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is added to the tag follower' do
|
||||||
|
expect(home_feed_of(tagf)).to include status.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with searchability private' do
|
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', anything)
|
||||||
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
expect(redis).to_not have_received(:publish).with('timeline:hashtag:hoge:local', anything)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'is not added to the tag follower' do
|
||||||
|
expect(home_feed_of(tagf)).to_not include status.id
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when local timeline is disabled' do
|
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
|
expect(home_feed_of(tom)).to_not include status.id
|
||||||
end
|
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
|
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:hashtag:hoge', anything)
|
||||||
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
|
expect(redis).to_not have_received(:publish).with('timeline:public', anything)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue