diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-03 14:07:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 14:07:29 +0100 |
commit | d1ecc323e7d435d0ffb11056a53b52d3345868f0 (patch) | |
tree | 0f4365ed24dc3638f52a385adee5280ec91d94dd /app/helpers/jsonld_helper.rb | |
parent | d0d15bf49c52c8329e3333397a9fc5d22341673a (diff) |
Compact JSON-LD signed incoming activities (#17426)
Co-authored-by: Puck Meerburg <puck@puck.moe>
Diffstat (limited to 'app/helpers/jsonld_helper.rb')
-rw-r--r-- | app/helpers/jsonld_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index c24d2ddf106..841f2774676 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module JsonLdHelper + include ContextHelper + def equals_or_includes?(haystack, needle) haystack.is_a?(Array) ? haystack.include?(needle) : haystack == needle end @@ -69,6 +71,12 @@ module JsonLdHelper graph.dump(:normalize) end + def compact(json) + compacted = JSON::LD::API.compact(json.without('signature'), full_context, documentLoader: method(:load_jsonld_context)) + compacted['signature'] = json['signature'] + compacted + end + def fetch_resource(uri, id, on_behalf_of = nil) unless id json = fetch_resource_without_id_validation(uri, on_behalf_of) |