diff options
author | pdp8 <pdp8@pdp8.info> | 2023-09-24 12:28:40 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-09-24 12:28:40 +0200 |
commit | 6100f9971b74ee4d3449155beb881a69017a296d (patch) | |
tree | bd2511b705847add76ea952ab6dd17aa1c0068c6 /client.rb | |
parent | 4dabdfb47154014f491462b026882102b5e668e3 (diff) |
undo reactivated, object names without published date, find_object helper
Diffstat (limited to 'client.rb')
-rw-r--r-- | client.rb | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -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) |