Skip to content
Snippets Groups Projects
Unverified Commit f31e58af authored by Eugen Rochko's avatar Eugen Rochko Committed by GitHub
Browse files

Fix nil error in StatusFilter (#7470)

Fix #7462
parent f1ed855f
No related branches found
No related tags found
No related merge requests found
......@@ -74,16 +74,7 @@ module StatusThreadingConcern
statuses = statuses_with_accounts(ids).to_a
account_ids = statuses.map(&:account_id).uniq
domains = statuses.map(&:account_domain).compact.uniq
relations = if account.present?
{
blocking: Account.blocking_map(account_ids, account.id),
blocked_by: Account.blocked_by_map(account_ids, account.id),
muting: Account.muting_map(account_ids, account.id),
following: Account.following_map(account_ids, account.id),
domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id),
}
end
relations = relations_map_for_account(account, account_ids, domains)
statuses.reject! { |status| filter_from_context?(status, account, relations) }
......@@ -91,6 +82,18 @@ module StatusThreadingConcern
statuses.sort_by! { |status| ids.index(status.id) }
end
def relations_map_for_account(account, account_ids, domains)
return {} if account.nil?
{
blocking: Account.blocking_map(account_ids, account.id),
blocked_by: Account.blocked_by_map(account_ids, account.id),
muting: Account.muting_map(account_ids, account.id),
following: Account.following_map(account_ids, account.id),
domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, account.id),
}
end
def statuses_with_accounts(ids)
Status.where(id: ids).includes(:account)
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