about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-21 22:07:18 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-21 22:07:18 +0200
commite46abc71cad590c2113247d41feca80d27a557b0 (patch)
tree7c7947aa82231a1d28fd2240a689ca057550ea1d /app/models
parent4bec613897d8835bb78202c7a36691b654f14967 (diff)
Fix notifications in UI, added new API for fetching account relationships
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb
index bfb10ae51..25316c9a4 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -127,6 +127,14 @@ class Account < ApplicationRecord
     nil
   end
 
+  def self.following_map(target_account_ids, account_id)
+    Follow.where(target_account_id: target_account_ids).where(account_id: account_id).map { |f| [f.target_account_id, true] }.to_h
+  end
+
+  def self.followed_by_map(target_account_ids, account_id)
+    Follow.where(account_id: target_account_ids).where(target_account_id: account_id).map { |f| [f.account_id, true] }.to_h
+  end
+
   before_create do
     if local?
       keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 1024 : 2048)