forked from cybrespace/mastodon
Case-insensitive search by usernames
This commit is contained in:
parent
a82f2e4b82
commit
54ea7f5dfe
|
@ -29,7 +29,7 @@ class AccountsController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = Account.find_by!(username: params[:username], domain: nil)
|
@account = Account.find_local!(params[:username])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_webfinger_header
|
def set_webfinger_header
|
||||||
|
|
|
@ -16,7 +16,7 @@ class StreamEntriesController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = Account.find_by!(username: params[:account_username], domain: nil)
|
@account = Account.find_local!(params[:account_username])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_stream_entry
|
def set_stream_entry
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ProcessMentionsService < BaseService
|
||||||
|
|
||||||
status.text.scan(Account::MENTION_RE).each do |match|
|
status.text.scan(Account::MENTION_RE).each do |match|
|
||||||
username, domain = match.first.split('@')
|
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?
|
if mentioned_account.nil? && !domain.nil?
|
||||||
mentioned_account = follow_remote_account_service.("#{match.first}")
|
mentioned_account = follow_remote_account_service.("#{match.first}")
|
||||||
|
|
Loading…
Reference in New Issue