diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-08-14 02:29:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 02:29:36 +0200 |
commit | 4e75f0d88932511ad154773f4c77a485367ed36c (patch) | |
tree | 3b0656542633fc80ac7b657d8ee2694ca8bc2fdc /app/helpers | |
parent | a2aeacbfeed5dc7070c37a22bb2c4bac1a58a526 (diff) |
Hook up URL-based resource look-up to ActivityPub (#4589)
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/jsonld_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index b0db025bc..c750a7038 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -16,7 +16,11 @@ module JsonLdHelper def fetch_resource(uri) response = build_request(uri).perform return if response.code != 200 - Oj.load(response.to_s, mode: :strict) + body_to_json(response.to_s) + end + + def body_to_json(body) + body.nil? ? nil : Oj.load(body, mode: :strict) rescue Oj::ParseError nil end @@ -25,7 +29,7 @@ module JsonLdHelper def build_request(uri) request = Request.new(:get, uri) - request.add_headers('Accept' => 'application/activity+json') + request.add_headers('Accept' => 'application/activity+json, application/ld+json') request end end |