diff options
author | pdp8 <pdp8@pdp8.info> | 2023-07-19 14:45:07 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-07-19 14:45:07 +0200 |
commit | edf5c00313b42308271fdad84a003b78a9483fc8 (patch) | |
tree | f4ee567fdecbe293c157cd7601d060aff0994833 /helpers.rb | |
parent | bd7e17e927824461c1af167fae292906b6212894 (diff) |
tags and mentions
Diffstat (limited to 'helpers.rb')
-rw-r--r-- | helpers.rb | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -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 |