From edf5c00313b42308271fdad84a003b78a9483fc8 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Wed, 19 Jul 2023 14:45:07 +0200 Subject: tags and mentions --- helpers.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'helpers.rb') diff --git a/helpers.rb b/helpers.rb index 3e24b82..0c668e9 100644 --- a/helpers.rb +++ b/helpers.rb @@ -19,6 +19,9 @@ helpers do activity_path = File.join(OUTBOX_DIR, activity_rel_path) activity['id'] = File.join(OUTBOX_URL, activity_rel_path) activity['published'] = httpdate + # assumes that recipient collections have been expanded by sender + # put all recipients into 'to', avoid 'cc' 'bto' 'bcc' 'audience' !! + activity['to'] = recipients if add_recipients # save object if activity['object'] && activity['object']['type'] && !activity['object']['id'] @@ -35,11 +38,7 @@ helpers do # save activity FileUtils.mkdir_p File.dirname(activity_path) File.open(activity_path, 'w+') { |f| f.puts activity.to_json } - update_collection OUTBOX, activity['id'] - # if type == 'Follow' - # jj activity - # update_collection FOLLO, activity['id'] - # end + update_collection OUTBOX, activity['id'] if %w[Create Announce].include?(type) # send # https://github.com/mastodon/mastodon/blob/main/app/lib/request.rb @@ -48,9 +47,6 @@ helpers do sha256 = OpenSSL::Digest.new('SHA256') digest = "SHA-256=#{sha256.base64digest(body)}" - # assumes that recipient collections have been expanded by sender - # put all recipients into 'to', avoid 'cc' 'bto' 'bcc' 'audience' !! - activity['to'] = recipients if add_recipients inboxes = [] recipients.uniq.each do |url| next if [ACTOR, 'https://www.w3.org/ns/activitystreams#Public'].include? url @@ -74,6 +70,7 @@ helpers do "-X POST -H 'Content-Type: application/activity+json' -H 'Host: #{uri.host}' -H 'Date: #{httpdate}' -H 'Digest: #{digest}' -H 'Signature: #{signed_header}' -d '#{body}'", inbox ) end + activity end def update_collection(path, objects, delete = false) @@ -109,12 +106,12 @@ helpers do response = curl( "-H 'Accept: #{accept}' -H 'Host: #{uri.host}' -H 'Date: #{httpdate}' -H 'Signature: #{signed_header}' ", url ) - # response = curl("-H 'Accept: #{accept}'", url) response ? JSON.parse(response) : nil end def curl(ext, url) p url + # p "/run/current-system/sw/bin/curl --fail-with-body -sSL #{ext} #{url}" response = `/run/current-system/sw/bin/curl --fail-with-body -sSL #{ext} #{url}` if $CHILD_STATUS.success? response -- cgit v1.2.3