about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-08-21 22:57:34 +0200
committerGitHub <noreply@github.com>2017-08-21 22:57:34 +0200
commit72bb3e03fdf4d8c886d41f3459000b336a3a362b (patch)
treeef5e3f97195bf55d04b49ac6cdf04b6394d8f686 /app/helpers
parentf391a4673adc6d79bb3a46b493d599a4bf6d558f (diff)
Support more variations of ActivityPub keyId in signature (#4630)
- Tries to avoid performing HTTP request if the keyId is an actor URI
- Likewise if the URI is a fragment URI on top of actor URI
- Resolves public key, returns owner if the owner links back to the key
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/jsonld_helper.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb
index c750a7038..d8b3ddf18 100644
--- a/app/helpers/jsonld_helper.rb
+++ b/app/helpers/jsonld_helper.rb
@@ -9,6 +9,10 @@ module JsonLdHelper
     value.is_a?(Array) ? value.first : value
   end
 
+  def value_or_id(value)
+    value.is_a?(String) ? value : value['id']
+  end
+
   def supported_context?(json)
     equals_or_includes?(json['@context'], ActivityPub::TagManager::CONTEXT)
   end
@@ -20,7 +24,7 @@ module JsonLdHelper
   end
 
   def body_to_json(body)
-    body.nil? ? nil : Oj.load(body, mode: :strict)
+    body.is_a?(String) ? Oj.load(body, mode: :strict) : body
   rescue Oj::ParseError
     nil
   end