diff options
author | pdp8 <pdp8@pdp8.info> | 2023-12-20 11:20:50 +0100 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-12-20 11:20:50 +0100 |
commit | 88518c5a4fa4fa9d841bb0d1c8add9fa2234530c (patch) | |
tree | 8a808ff352841779637c6bd1aa171e94c2c55cdf /client.rb | |
parent | 443b6fd42abf9cb1392125199cca449702898327 (diff) |
follow, announce, delete fixed
Diffstat (limited to 'client.rb')
-rw-r--r-- | client.rb | 59 |
1 files changed, 32 insertions, 27 deletions
@@ -1,20 +1,20 @@ # client-server -['/inbox/object', '/outbox/object'].each do |path| - get path do - protected! - Dir[File.join(path.sub('/', ''), '*', '*.json')].collect { |f| JSON.load_file(f) }.to_json - end -end +# ['/inbox/object', '/outbox/object'].each do |path| +# get path do +# protected! +# Dir[File.join(path.sub('/', ''), '*', '*.json')].collect { |f| JSON.load_file(f) }.to_json +# end +# end -post '/delete' do - protected! - params['id'].each do |id| - file, object = find_object id - halt 404 unless file and File.exist?(file) - FileUtils.rm(file) - end - 200 -end +# post '/delete' do +# protected! +# params['id'].each do |id| +# file, object = find_object id +# halt 404 unless file and File.exist?(file) +# FileUtils.rm(file) +# end +# 200 +# end post '/follow' do protected! @@ -29,26 +29,31 @@ post '/unfollow' do following = Dir[File.join(OUTBOX[:dir], 'follow', '*.json')].collect { |f| JSON.load_file(f) } activity = following.find { |a| a['object'] == params['id'] } activity ||= { - "@context": 'https://www.w3.org/ns/activitystreams', - "type": 'Follow', - "actor": 'https://social.pdp8.info/pdp8', - "object": params['id'] + '@context' => 'https://www.w3.org/ns/activitystreams', + 'type' => 'Follow', + 'actor' => 'https://social.pdp8.info/pdp8', + 'object' => params['id'] } create_activity 'Undo', activity, [params['id']] update_collection FOLLOWING, params['id'], 'delete' 200 end -post '/share' do # TODO +post '/announce' do # TODO protected! - src, object = find_object params['id'] - object = JSON.load_file(src) + # src, object = find_object params['id'] + # object = JSON.load_file(src) + # to = ['https://www.w3.org/ns/activitystreams#Public', FOLLOWERS_URL] + # to << object['attributedTo'] + # create_activity 'Announce', object, to + # src, object = find_object params['id'] + # object = JSON.load_file(src) 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 + to << params['attributedTo'] + create_activity 'Announce', params['id'], to + # dest = src.sub('inbox/', 'outbox/') + # FileUtils.mkdir_p File.dirname(dest) + # FileUtils.rm src 200 end |