# frozen_string_literal: true
module AuthorExtractor
- def author_from_xml(xml)
+ def author_from_xml(xml, update_profile = true)
return nil if xml.nil?
# Try <email> for acct
acct = "#{username}@#{domain}"
end
- FollowRemoteAccountService.new.call(acct)
+ FollowRemoteAccountService.new.call(acct, update_profile)
end
end
xml = Nokogiri::XML(body)
xml.encoding = 'utf-8'
- account = author_from_xml(xml.at_xpath('/xmlns:feed', xmlns: TagManager::XMLNS))
+ account = author_from_xml(xml.at_xpath('/xmlns:feed', xmlns: TagManager::XMLNS), false)
UpdateRemoteProfileService.new.call(xml, account) unless account.nil?
# important information from their feed
# @param [String] uri User URI in the form of username@domain
# @return [Account]
- def call(uri, redirected = nil)
+ def call(uri, update_profile = true, redirected = nil)
username, domain = uri.split('@')
return Account.find_local(username) if TagManager.instance.local_domain?(domain)
confirmed_username, confirmed_domain = data.subject.gsub(/\Aacct:/, '').split('@')
unless confirmed_username.casecmp(username).zero? && confirmed_domain.casecmp(domain).zero?
- return call("#{confirmed_username}@#{confirmed_domain}", true) if redirected.nil?
+ return call("#{confirmed_username}@#{confirmed_domain}", update_profile, true) if redirected.nil?
raise Goldfinger::Error, 'Requested and returned acct URI do not match'
end
begin
account.save!
- get_profile(body, account)
+ get_profile(body, account) if update_profile
rescue ActiveRecord::RecordNotUnique
# The account has been added by another worker!
return Account.find_remote(confirmed_username, confirmed_domain)