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