Extract visibility_scope method to re-use existing scopes in AccountStatusesFilter (#40316)
This commit is contained in:
1 parent
0e76219b38
commit
4a1984c20e
1 file changed
+10
-2
@@ -49,10 +49,10 @@ class AccountStatusesFilter
|
||||
scope = account.statuses
|
||||
|
||||
if exclude_direct?
|
||||
scope = scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted))
|
||||
scope = visibility_scope(scope)
|
||||
else
|
||||
scope = account.statuses.left_outer_joins(:mentions)
|
||||
scope.merge!(scope.where(visibility: follower? ? %i(public unlisted private) : %i(public unlisted)).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id]))
|
||||
scope.merge!(visibility_scope(scope).or(scope.where(mentions: { account_id: current_account.id })).group(Status.arel_table[:id]))
|
||||
end
|
||||
|
||||
scope.merge!(filtered_reblogs_scope) if reblogs_may_occur?
|
||||
@@ -60,6 +60,14 @@ class AccountStatusesFilter
|
||||
scope
|
||||
end
|
||||
|
||||
def visibility_scope(scope)
|
||||
if follower?
|
||||
scope.list_eligible_visibility
|
||||
else
|
||||
scope.distributable_visibility
|
||||
end
|
||||
end
|
||||
|
||||
def filtered_reblogs_scope
|
||||
scope = Status.left_outer_joins(reblog: :account)
|
||||
scope
|
||||
|
||||
Reference in new issue
Block a user