Filter direct statuses in Status.as_home_timeline (#3842)
The classes using Status.as_home_timeline, namely Feed and PrecomputeFeedService are expected to filter direct statuses as FanOutWriteService does, but their filtering were incomplete or missing. This commit solves the problem by filtering direct statuses in as_home_timeline as the other similar methods such as as_public_timeline does.
This commit is contained in:
committed by
Eugen Rochko
parent
a20cf3b64e
commit
bab5a18232
@ -131,7 +131,15 @@ class Status < ApplicationRecord
|
||||
end
|
||||
|
||||
def as_home_timeline(account)
|
||||
where(account: [account] + account.following)
|
||||
# 'references' is a workaround for the following issue:
|
||||
# Inconsistent results with #or in ActiveRecord::Relation with respect to documentation Issue #24055 rails/rails
|
||||
# https://github.com/rails/rails/issues/24055
|
||||
references(:mentions)
|
||||
.where.not(visibility: :direct)
|
||||
.or(where(mentions: { account: account }))
|
||||
.where(follows: { account_id: account })
|
||||
.or(references(:mentions, :follows).where(account: account))
|
||||
.left_outer_joins(account: :followers).left_outer_joins(:mentions).group(:id)
|
||||
end
|
||||
|
||||
def as_public_timeline(account = nil, local_only = false)
|
||||
|
Reference in New Issue
Block a user