From f2404de871f0bdfda5c9aeeeb4c6c4d10a8da8ab Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 9 Aug 2018 09:56:53 +0200 Subject: Public profile endorsements (accounts picked by profile owner) (#8146) --- app/models/concerns/account_interactions.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models/concerns') diff --git a/app/models/concerns/account_interactions.rb b/app/models/concerns/account_interactions.rb index e14e041f6..f5f833446 100644 --- a/app/models/concerns/account_interactions.rb +++ b/app/models/concerns/account_interactions.rb @@ -40,6 +40,10 @@ module AccountInteractions end end + def endorsed_map(target_account_ids, account_id) + follow_mapping(AccountPin.where(account_id: account_id, target_account_id: target_account_ids), :target_account_id) + end + def domain_blocking_map(target_account_ids, account_id) accounts_map = Account.where(id: target_account_ids).select('id, domain').map { |a| [a.id, a.domain] }.to_h blocked_domains = domain_blocking_map_by_domain(accounts_map.values.compact, account_id) @@ -190,6 +194,10 @@ module AccountInteractions status_pins.where(status: status).exists? end + def endorsed?(account) + account_pins.where(target_account: account).exists? + end + def followers_for_local_distribution followers.local .joins(:user) -- cgit