summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb59
1 files changed, 32 insertions, 27 deletions
diff --git a/client.rb b/client.rb
index 01124bc..e0a5746 100644
--- a/client.rb
+++ b/client.rb
@@ -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