about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/follow_remote_account_service.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index 0a95badb2..b309425a8 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -15,16 +15,25 @@ class FollowRemoteAccountService < BaseService
     return nil if DomainBlock.blocked?(domain)
 
     account = Account.find_remote(username, domain)
-
     return account unless account.nil?
 
-    Rails.logger.debug "Creating new remote account for #{uri}"
+    Rails.logger.debug "Looking up webfinger for #{uri}"
+
     account = Account.new(username: username, domain: domain)
 
     data = Goldfinger.finger("acct:#{uri}")
 
     raise Goldfinger::Error, 'Missing resource links' if data.link('http://schemas.google.com/g/2010#updates-from').nil? || data.link('salmon').nil? || data.link('http://webfinger.net/rel/profile-page').nil? || data.link('magic-public-key').nil?
 
+    confirmed_username, confirmed_domain = data.subject.gsub(/\Aacct:/, '').split('@')
+
+    return Account.find_local(confirmed_username) if TagManager.instance.local_domain?(confirmed_domain)
+
+    confirmed_account = Account.find_remote(confirmed_username, confirmed_domain)
+    return confirmed_account unless confirmed_account.nil?
+
+    Rails.logger.debug "Creating new remote account for #{uri}"
+
     account.remote_url  = data.link('http://schemas.google.com/g/2010#updates-from').href
     account.salmon_url  = data.link('salmon').href
     account.url         = data.link('http://webfinger.net/rel/profile-page').href