Change list exclusive setting to apply antenna accounts
This commit is contained in:
parent
2b74bcd6b8
commit
58583cb7bb
2 changed files with 40 additions and 1 deletions
|
@ -411,7 +411,7 @@ class FeedManager
|
||||||
def filter_from_home?(status, receiver_id, crutches, timeline_type = :home, stl_home = false) # rubocop:disable Style/OptionalBooleanParameter
|
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 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 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)
|
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] || []
|
check_for_blocks = crutches[:active_mentions][status.id] || []
|
||||||
|
@ -602,6 +602,7 @@ class FeedManager
|
||||||
end
|
end
|
||||||
|
|
||||||
lists = List.where(account_id: receiver_id, exclusive: true)
|
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[: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
|
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[: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[: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_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
|
crutches
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,6 +27,7 @@ RSpec.describe FeedManager do
|
||||||
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||||
let(:jeff) { Fabricate(:account, username: 'jeff') }
|
let(:jeff) { Fabricate(:account, username: 'jeff') }
|
||||||
let(:list) { Fabricate(:list, account: alice) }
|
let(:list) { Fabricate(:list, account: alice) }
|
||||||
|
let(:antenna) { Fabricate(:antenna, account: alice, insert_feeds: true, list: list) }
|
||||||
|
|
||||||
context 'with home feed' do
|
context 'with home feed' do
|
||||||
it 'returns false for followee\'s status' do
|
it 'returns false for followee\'s status' do
|
||||||
|
@ -190,6 +191,42 @@ RSpec.describe FeedManager do
|
||||||
reblog = Fabricate(:status, reblog: status, account: jeff)
|
reblog = Fabricate(:status, reblog: status, account: jeff)
|
||||||
expect(described_class.instance.filter?(:home, reblog, alice)).to be false
|
expect(described_class.instance.filter?(:home, reblog, alice)).to be false
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'with mentions feed' do
|
context 'with mentions feed' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue