summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-10-06 15:02:59 +0200
committerpdp8 <pdp8@pdp8.info>2023-10-06 15:02:59 +0200
commit580c684f792d6fab16c58b9a08d566cd03c72ca4 (patch)
treeb6cda32267d02c5e5118fa2d6b1da92c48c457c6 /client.rb
parent6100f9971b74ee4d3449155beb881a69017a296d (diff)
announce to fixed, find_file replaced with find_object, CONTENT_LENGHT included in signature verification
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/client.rb b/client.rb
index 7b93c83..01124bc 100644
--- a/client.rb
+++ b/client.rb
@@ -41,12 +41,11 @@ end
post '/share' do # TODO
protected!
- src = find_file params['id']
+ src, object = find_object params['id']
object = JSON.load_file(src)
- recipients = ['https://www.w3.org/ns/activitystreams#Public']
- recipients += JSON.load_file(FOLLOWERS)['orderedItems']
- recipients << object['attributedTo']
- create_activity 'Announce', object, recipients
+ to = ['https://www.w3.org/ns/activitystreams#Public', FOLLOWERS_URL]
+ to << object['attributedTo']
+ create_activity 'Announce', object, to
dest = src.sub('inbox/', 'outbox/')
FileUtils.mkdir_p File.dirname(dest)
FileUtils.mv src, dest
@@ -59,7 +58,7 @@ post '/undo' do # TODO: generalize for announce
activity = JSON.load_file(activity_file)
next unless activity['id'] == params['id']
- object_file = find_file activity['object']['id']
+ object_file, object = find_object activity['object']['id']
create_activity 'Undo', params['id'], activity['to']
FileUtils.rm(activity_file)
FileUtils.rm(object_file)