diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-01-04 04:56:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 04:56:04 +0100 |
commit | 7d4f4f9aab7253540a69d2e80ba5414ae57a6582 (patch) | |
tree | bb1bee6f18337b0aadaba136252fc0b43dec538d /app | |
parent | 256c2b1de05e5c622ab914f6f353ed0a94d2faaa (diff) |
Fix FetchAtomService not finding alternatives if there's a Link header (#6170)
without them, such as is the case with GNU social Fixes the ability to find GNU social accounts via URL in search and when using remote follow function
Diffstat (limited to 'app')
-rw-r--r-- | app/services/fetch_atom_service.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb index 1c47a22da..c01e8d071 100644 --- a/app/services/fetch_atom_service.rb +++ b/app/services/fetch_atom_service.rb @@ -50,7 +50,7 @@ class FetchAtomService < BaseService @unsupported_activity = true nil end - elsif @response['Link'] && !terminal + elsif @response['Link'] && !terminal && link_header.find_link(%w(rel alternate)) process_headers elsif @response.mime_type == 'text/html' && !terminal process_html @@ -70,8 +70,6 @@ class FetchAtomService < BaseService end def process_headers - link_header = LinkHeader.parse(@response['Link'].is_a?(Array) ? @response['Link'].first : @response['Link']) - json_link = link_header.find_link(%w(rel alternate), %w(type application/activity+json)) || link_header.find_link(%w(rel alternate), ['type', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"']) atom_link = link_header.find_link(%w(rel alternate), %w(type application/atom+xml)) @@ -80,4 +78,8 @@ class FetchAtomService < BaseService result end + + def link_header + @link_header ||= LinkHeader.parse(@response['Link'].is_a?(Array) ? @response['Link'].first : @response['Link']) + end end |