|
|
|
@ -96,8 +96,12 @@ class Account < ApplicationRecord
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.find_local!(username)
|
|
|
|
|
self.find_remote!(username, nil)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.find_remote!(username, domain)
|
|
|
|
|
table = self.arel_table
|
|
|
|
|
self.where(table[:username].matches(username)).where(domain: nil).take!
|
|
|
|
|
self.where(table[:username].matches(username)).where(domain: domain).take!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.find_local(username)
|
|
|
|
@ -106,6 +110,12 @@ class Account < ApplicationRecord
|
|
|
|
|
nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def self.find_remote(username, domain)
|
|
|
|
|
self.find_remote!(username, domain)
|
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
|
nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before_create do
|
|
|
|
|
if local?
|
|
|
|
|
keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 1024 : 2048)
|
|
|
|
|