From 6100f9971b74ee4d3449155beb881a69017a296d Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sun, 24 Sep 2023 12:28:40 +0200 Subject: undo reactivated, object names without published date, find_object helper --- helpers.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'helpers.rb') diff --git a/helpers.rb b/helpers.rb index 536a7c6..0a7f829 100644 --- a/helpers.rb +++ b/helpers.rb @@ -80,7 +80,6 @@ helpers do signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), string)) signed_header = "keyId=\"#{ACTOR}#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest content-type\",signature=\"#{signature}\"" - p inbox # Net::HTTP fails with OpenSSL error curl( "-X POST -H 'Host: #{uri.host}' -H 'Date: #{httpdate}' -H 'Digest: #{digest}' -H 'Signature: #{signed_header}' --data-binary '@#{activity_path}'", inbox @@ -204,8 +203,14 @@ helpers do def find_file(id) Dir[File.join('*', 'object', '*', '*.json')].find do |f| - # Dir[File.join('*box', '**', '*.json')].find do |f| JSON.load_file(f)['id'] == id end end + + def find_object(id) + Dir[File.join('*', '**', '*.json')].each do |file| + object = JSON.load_file(file) + return [file, object] if object['id'] == id + end + end end -- cgit v1.2.3