]> cat aescling's git repositories - mastodon.git/commitdiff
Fix duplicate accounts being created when fetching an account for its key only (...
authorThibG <thib@sitedethib.com>
Mon, 24 Feb 2020 20:15:53 +0000 (21:15 +0100)
committerGitHub <noreply@github.com>
Mon, 24 Feb 2020 20:15:53 +0000 (21:15 +0100)
Fixes #13136

When a user's canonical acct domain is different from its id's domain
(WEB_DOMAIN ≠ LOCAL_DOMAIN), two webfinger queries are required to find the
canonical domain from the URI. However, we skip webfinger queries when
updating only the key of a remote user, which led to the creation of a
duplicate account, using the URI's domain instead of the canonical acct: one.

app/services/activitypub/process_account_service.rb

index cef658e191ee3fb667e62a6bd6a61dd04f847e2a..d5ede03886ace50edeae45e1a009b5f035deea09 100644 (file)
@@ -18,9 +18,10 @@ class ActivityPub::ProcessAccountService < BaseService
 
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
-        @account        = Account.find_remote(@username, @domain)
-        @old_public_key = @account&.public_key
-        @old_protocol   = @account&.protocol
+        @account          = Account.remote.find_by(uri: @uri) if @options[:only_key]
+        @account        ||= Account.find_remote(@username, @domain)
+        @old_public_key   = @account&.public_key
+        @old_protocol     = @account&.protocol
 
         create_account if @account.nil?
         update_account