mirror of
https://github.com/mastodon/mastodon.git
synced 2026-05-14 00:00:04 -05:00
Harden account processing code
This commit is contained in:
parent
52952873a0
commit
91c8bd00d6
|
|
@ -28,8 +28,15 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
@options[:request_id] ||= "#{Time.now.utc.to_i}-#{username}@#{domain}"
|
||||
|
||||
with_redis_lock("process_account:#{@uri}") do
|
||||
@account = Account.remote.find_by(uri: @uri) if @options[:only_key]
|
||||
@account ||= Account.find_remote(@username, @domain)
|
||||
if @options[:only_key]
|
||||
# `only_key` is used to update an existing account known by its `uri`.
|
||||
# Lookup by handle and new account creation do not make sense in this case.
|
||||
@account = Account.remote.find_by(uri: @uri)
|
||||
return if @account.nil?
|
||||
else
|
||||
@account = Account.find_remote(@username, @domain)
|
||||
end
|
||||
|
||||
@old_public_key = @account&.public_key
|
||||
@old_protocol = @account&.protocol
|
||||
@suspension_changed = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user