diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 97a42c52ee..7d530906c6 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -411,7 +411,7 @@ class FeedManager def filter_from_home?(status, receiver_id, crutches, timeline_type = :home, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter return false if receiver_id == status.account_id return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?) - return true if (timeline_type != :list || stl_home) && crutches[:exclusive_list_users][status.account_id].present? + return true if (timeline_type != :list || stl_home) && (crutches[:exclusive_list_users][status.account_id].present? || crutches[:exclusive_antenna_users][status.account_id].present?) return true if crutches[:languages][status.account_id].present? && status.language.present? && !crutches[:languages][status.account_id].include?(status.language) check_for_blocks = crutches[:active_mentions][status.id] || [] @@ -602,6 +602,7 @@ class FeedManager end lists = List.where(account_id: receiver_id, exclusive: true) + antennas = Antenna.where(list: lists, insert_feeds: true) crutches[:following] = Follow.where(account_id: receiver_id, target_account_id: statuses.filter_map(&:in_reply_to_account_id)).pluck(:target_account_id).index_with(true) crutches[:languages] = Follow.where(account_id: receiver_id, target_account_id: statuses.map(&:account_id)).pluck(:target_account_id, :languages).to_h @@ -611,6 +612,7 @@ class FeedManager crutches[:domain_blocking] = AccountDomainBlock.where(account_id: receiver_id, domain: statuses.flat_map { |s| [s.account.domain, s.reblog&.account&.domain] }.compact).pluck(:domain).index_with(true) crutches[:blocked_by] = Block.where(target_account_id: receiver_id, account_id: statuses.map { |s| [s.account_id, s.reblog&.account_id] }.flatten.compact).pluck(:account_id).index_with(true) crutches[:exclusive_list_users] = ListAccount.where(list: lists, account_id: statuses.map(&:account_id)).pluck(:account_id).index_with(true) + crutches[:exclusive_antenna_users] = AntennaAccount.where(antenna: antennas, account_id: statuses.map(&:account_id)).pluck(:account_id).index_with(true) crutches end diff --git a/spec/lib/feed_manager_spec.rb b/spec/lib/feed_manager_spec.rb index 25edaada64..d2e5da6b92 100644 --- a/spec/lib/feed_manager_spec.rb +++ b/spec/lib/feed_manager_spec.rb @@ -27,6 +27,7 @@ RSpec.describe FeedManager do let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') } let(:jeff) { Fabricate(:account, username: 'jeff') } let(:list) { Fabricate(:list, account: alice) } + let(:antenna) { Fabricate(:antenna, account: alice, insert_feeds: true, list: list) } context 'with home feed' do it 'returns false for followee\'s status' do @@ -190,6 +191,42 @@ RSpec.describe FeedManager do reblog = Fabricate(:status, reblog: status, account: jeff) expect(described_class.instance.filter?(:home, reblog, alice)).to be false end + + it 'returns true for post from followee on exclusive antenna' do + list.exclusive = true + alice.follow!(bob) + antenna.accounts << bob + allow(Antenna).to receive(:where).and_return(antenna) + status = Fabricate(:status, text: 'I post a lot', account: bob) + expect(described_class.instance.filter?(:home, status, alice)).to be true + end + + it 'returns true for reblog from followee on exclusive antenna' do + list.exclusive = true + alice.follow!(jeff) + antenna.accounts << jeff + allow(Antenna).to receive(:where).and_return(antenna) + status = Fabricate(:status, text: 'I post a lot', account: bob) + reblog = Fabricate(:status, reblog: status, account: jeff) + expect(described_class.instance.filter?(:home, reblog, alice)).to be true + end + + it 'returns false for post from followee on non-exclusive antenna' do + list.exclusive = false + alice.follow!(bob) + antenna.accounts << bob + status = Fabricate(:status, text: 'I post a lot', account: bob) + expect(described_class.instance.filter?(:home, status, alice)).to be false + end + + it 'returns false for reblog from followee on non-exclusive antenna' do + list.exclusive = false + alice.follow!(jeff) + antenna.accounts << jeff + status = Fabricate(:status, text: 'I post a lot', account: bob) + reblog = Fabricate(:status, reblog: status, account: jeff) + expect(described_class.instance.filter?(:home, reblog, alice)).to be false + end end context 'with mentions feed' do