diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-03 17:02:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-03 17:02:18 +0200 |
commit | bafd22ecf487774c252a271d668716b0e1c84c6c (patch) | |
tree | bda1f7d712b3d0094595b56261a36b38034d345b /app/services/fetch_remote_account_service.rb | |
parent | dd9d57300ba3b6df91ef6398d8c369437cc2a9c7 (diff) |
Fix #2706 - Always respond with 200 to PuSH payloads (#2733)
Fix #2196 - Respond with 201 when Salmon accepted, 400 when unverified Fix #2629 - Correctly handle confirm_domain? for local accounts Unify rules for extracting author acct from XML, prefer <email>, fall back to <name> + <uri> (see also #2017, #2172)
Diffstat (limited to 'app/services/fetch_remote_account_service.rb')
-rw-r--r-- | app/services/fetch_remote_account_service.rb | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb index 7c2fb0ef1..98fdf3dfe 100644 --- a/app/services/fetch_remote_account_service.rb +++ b/app/services/fetch_remote_account_service.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class FetchRemoteAccountService < BaseService + include AuthorExtractor + def call(url, prefetched_body = nil) if prefetched_body.nil? atom_url, body = FetchAtomService.new.call(url) @@ -19,21 +21,10 @@ class FetchRemoteAccountService < BaseService xml = Nokogiri::XML(body) xml.encoding = 'utf-8' - email = xml.at_xpath('//xmlns:author/xmlns:email').try(:content) - if email.nil? - url_parts = Addressable::URI.parse(url).normalize - username = xml.at_xpath('//xmlns:author/xmlns:name').try(:content) - domain = url_parts.host - else - username, domain = email.split('@') - end - - return nil if username.nil? || domain.nil? - - Rails.logger.debug "Going to webfinger #{username}@#{domain}" + account = author_from_xml(xml.at_xpath('/xmlns:feed', xmlns: TagManager::XMLNS)) - account = FollowRemoteAccountService.new.call("#{username}@#{domain}") UpdateRemoteProfileService.new.call(xml, account) unless account.nil? + account rescue TypeError Rails.logger.debug "Unparseable URL given: #{url}" |