summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb29
1 files changed, 14 insertions, 15 deletions
diff --git a/client.rb b/client.rb
index 8af00c9..7b93c83 100644
--- a/client.rb
+++ b/client.rb
@@ -9,7 +9,7 @@ end
post '/delete' do
protected!
params['id'].each do |id|
- file = find_file id
+ file, object = find_object id
halt 404 unless file and File.exist?(file)
FileUtils.rm(file)
end
@@ -53,20 +53,19 @@ post '/share' do # TODO
200
end
-# post '/undo' do # TODO: generalize for announce
-# protected!
-# activity_file = find_file(params['id'])
-# Dir[File.join('outbox', '*', '*.json')].each do |f|
-# activity = JSON.load_file(f)
-# next unless activity['id'] == params['id']
-#
-# object_file = find_file activity['object']['id']
-# create_activity 'Undo', params['id'], activity['to']
-# FileUtils.rm(object_file)
-# FileUtils.rm(f)
-# end
-# 200
-# end
+post '/undo' do # TODO: generalize for announce
+ protected!
+ Dir[File.join('outbox', '*', '*.json')].each do |activity_file|
+ activity = JSON.load_file(activity_file)
+ next unless activity['id'] == params['id']
+
+ object_file = find_file activity['object']['id']
+ create_activity 'Undo', params['id'], activity['to']
+ FileUtils.rm(activity_file)
+ FileUtils.rm(object_file)
+ end
+ 200
+end
post '/login' do
session['client'] = (OpenSSL::Digest::SHA256.base64digest(params['secret']) == File.read('.digest').chomp)