Merge pull request #993 from kmycode/kbtopic-fix-stl-feed

Fix: STL配置判定時、エラーで落ちる問題
This commit is contained in:
KMY(雪あすか) 2025-03-14 19:14:56 +09:00 committed by GitHub
parent 6a3c70c4ff
commit a24031b527
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -51,7 +51,7 @@ class FeedManager
when :home when :home
filter_from_home(status, receiver.id, build_crutches(receiver.id, [status]), :home) filter_from_home(status, receiver.id, build_crutches(receiver.id, [status]), :home)
when :list when :list
(filter_from_list?(status, receiver) ? :filter : nil) || filter_from_home(status, receiver.account_id, build_crutches(receiver.account_id, [status], list: receiver), :list, stl_home: stl_home) (filter_from_list?(status, receiver) ? :filter : nil) || filter_from_home(status, receiver.account_id, build_crutches(receiver.account_id, [status], list: receiver, stl_home: stl_home), :list, stl_home: stl_home)
when :mentions when :mentions
filter_from_mentions?(status, receiver.id) ? :filter : nil filter_from_mentions?(status, receiver.id) ? :filter : nil
when :tags when :tags
@ -661,7 +661,7 @@ class FeedManager
# @param [Array<Status>] statuses # @param [Array<Status>] statuses
# @param [List] list # @param [List] list
# @return [Hash] # @return [Hash]
def build_crutches(receiver_id, statuses, list: nil) def build_crutches(receiver_id, statuses, list: nil, stl_home: false)
crutches = {} crutches = {}
crutches[:active_mentions] = crutches_active_mentions(statuses) crutches[:active_mentions] = crutches_active_mentions(statuses)
@ -685,7 +685,7 @@ class FeedManager
crutches[:muting] = Mute.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).index_with(true) crutches[:muting] = Mute.where(account_id: receiver_id, target_account_id: check_for_blocks).pluck(:target_account_id).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[: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] = crutches_exclusive_list_users(receiver_id, statuses) if list.blank? crutches[:exclusive_list_users] = crutches_exclusive_list_users(receiver_id, statuses) if list.nil? || stl_home
crutches[:exclusive_antenna_users] = crutches_exclusive_antenna_users(receiver_id, statuses) crutches[:exclusive_antenna_users] = crutches_exclusive_antenna_users(receiver_id, statuses)
crutches crutches

View file

@ -255,6 +255,17 @@ RSpec.describe FeedManager do
end end
end end
context 'with stl list feed' do
let(:antenna) { Fabricate(:antenna, account: bob, insert_feeds: true, list_id: list.id, stl: true) }
let(:list) { Fabricate(:list, account: bob) }
it "returns false for followee's status" do
status = Fabricate(:status, text: 'Hello world', account: alice, visibility: :unlisted)
expect(subject.filter?(:list, status, list, stl_home: true)).to be false
end
end
context 'with mentions feed' do context 'with mentions feed' do
it 'returns true for status that mentions blocked account' do it 'returns true for status that mentions blocked account' do
bob.block!(jeff) bob.block!(jeff)