0
0
Fork 0

Refactoring relations_map (#24195)

This commit is contained in:
Takeshi Umeda 2023-03-21 18:32:58 +09:00 committed by GitHub
parent 9f8d1601a4
commit 38c84f57b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 35 deletions

View file

@ -292,6 +292,21 @@ module AccountInteractions
end
end
def relations_map(account_ids, domains = nil, **options)
relations = {
blocked_by: Account.blocked_by_map(account_ids, id),
following: Account.following_map(account_ids, id),
}
return relations if options[:skip_blocking_and_muting]
relations.merge!({
blocking: Account.blocking_map(account_ids, id),
muting: Account.muting_map(account_ids, id),
domain_blocking_by_domain: Account.domain_blocking_map_by_domain(domains, id),
})
end
private
def remove_potential_friendship(other_account)

View file

@ -79,7 +79,7 @@ module StatusThreadingConcern
statuses = Status.with_accounts(ids).to_a
account_ids = statuses.map(&:account_id).uniq
domains = statuses.filter_map(&:account_domain).uniq
relations = relations_map_for_account(account, account_ids, domains)
relations = account&.relations_map(account_ids, domains) || {}
statuses.reject! { |status| StatusFilter.new(status, account, relations).filtered? }
@ -108,16 +108,4 @@ module StatusThreadingConcern
arr
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
end