|
|
@ -133,37 +133,39 @@ class Account < ApplicationRecord
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.find_local!(username)
|
|
|
|
class << self
|
|
|
|
|
|
|
|
def find_local!(username)
|
|
|
|
find_remote!(username, nil)
|
|
|
|
find_remote!(username, nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.find_remote!(username, domain)
|
|
|
|
def find_remote!(username, domain)
|
|
|
|
where(arel_table[:username].matches(username)).where(domain.nil? ? { domain: nil } : arel_table[:domain].matches(domain)).take!
|
|
|
|
where(arel_table[:username].matches(username)).where(domain.nil? ? { domain: nil } : arel_table[:domain].matches(domain)).take!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.find_local(username)
|
|
|
|
def find_local(username)
|
|
|
|
find_local!(username)
|
|
|
|
find_local!(username)
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
nil
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.find_remote(username, domain)
|
|
|
|
def find_remote(username, domain)
|
|
|
|
find_remote!(username, domain)
|
|
|
|
find_remote!(username, domain)
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
nil
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.following_map(target_account_ids, account_id)
|
|
|
|
def 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
|
|
|
|
Follow.where(target_account_id: target_account_ids).where(account_id: account_id).map { |f| [f.target_account_id, true] }.to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.followed_by_map(target_account_ids, account_id)
|
|
|
|
def 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
|
|
|
|
Follow.where(account_id: target_account_ids).where(target_account_id: account_id).map { |f| [f.account_id, true] }.to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def self.blocking_map(target_account_ids, account_id)
|
|
|
|
def blocking_map(target_account_ids, account_id)
|
|
|
|
Block.where(target_account_id: target_account_ids).where(account_id: account_id).map { |b| [b.target_account_id, true] }.to_h
|
|
|
|
Block.where(target_account_id: target_account_ids).where(account_id: account_id).map { |b| [b.target_account_id, true] }.to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
before_create do
|
|
|
|
before_create do
|
|
|
|
if local?
|
|
|
|
if local?
|
|
|
|