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)
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)
status.text.scan(Account::MENTION_RE).each do |match|
username, domain = match.first.split('@')
- mentioned_account = Account.find_by(username: username, domain: domain)
+ mentioned_account = Account.find_remote(username, domain)
if mentioned_account.nil? && !domain.nil?
mentioned_account = follow_remote_account_service.("#{match.first}")