Skip to content
Snippets Groups Projects
Commit 7bacdd71 authored by Akihiko Odaki (@fn_aki@pawoo.net)'s avatar Akihiko Odaki (@fn_aki@pawoo.net) Committed by Eugen Rochko
Browse files

Fix PrecomputeFeedService for filtered statuses (#4148)

parent 958fe0f7
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ class PrecomputeFeedService < BaseService
attr_reader :account
def populate_feed
pairs = statuses.reverse_each.map(&method(:process_status))
pairs = statuses.reverse_each.lazy.reject(&method(:status_filtered?)).map(&method(:process_status)).to_a
redis.pipelined do
redis.zadd(account_home_key, pairs) if pairs.any?
......@@ -22,7 +22,7 @@ class PrecomputeFeedService < BaseService
end
def process_status(status)
[status.id, status.reblog? ? status.reblog_of_id : status.id] unless status_filtered?(status)
[status.id, status.reblog? ? status.reblog_of_id : status.id]
end
def status_filtered?(status)
......
......@@ -23,5 +23,17 @@ RSpec.describe PrecomputeFeedService do
account = Fabricate(:account)
subject.call(account)
end
it 'filters statuses' do
account = Fabricate(:account)
muted_account = Fabricate(:account)
Fabricate(:mute, account: account, target_account: muted_account)
reblog = Fabricate(:status, account: muted_account)
status = Fabricate(:status, account: account, reblog: reblog)
subject.call(account)
expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment