From e46abc71cad590c2113247d41feca80d27a557b0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 21 Sep 2016 22:07:18 +0200 Subject: Fix notifications in UI, added new API for fetching account relationships --- app/models/account.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models') 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) -- cgit