summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-08-24 15:52:39 +0200
committerpdp8 <pdp8@pdp8.info>2023-08-24 15:52:39 +0200
commit485d71e69cb5b56d3ccf8b5eb82ef6af9d172485 (patch)
tree8d353aed6b5dacf34c8be426881ee03d6b3602ab /client.rb
parent8cb9bc7e4d516a27b4fe27ba0d0a9c40497e003d (diff)
like, move, delete, update activities
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/client.rb b/client.rb
index 13ba3a6..0ebd3aa 100644
--- a/client.rb
+++ b/client.rb
@@ -10,24 +10,24 @@ post '/delete' do
protected!
params['id'].each do |id|
file = find_file id
- if file.match(%r{outbox/}) # find/delete activity
+ # if file.match(%r{outbox/}) # find/delete activity
- Dir[File.join 'outbox', 'announce', '*'].each do |announce_file|
- announce = JSON.load_file(announce_file)
- next unless announce['object']['id'] == id
+ Dir[File.join 'outbox', 'announce', '*'].each do |announce_file|
+ announce = JSON.load_file(announce_file)
+ next unless announce['object']['id'] == id
- outbox 'Undo', announce, announce['to']
- FileUtils.rm(announce_file)
- end
- Dir[File.join 'outbox', 'create', '*'].each do |create_file|
- create = JSON.load_file(create_file)
- next unless create['object']['id'] == id
+ outbox 'Undo', announce, announce['to']
+ FileUtils.rm(announce_file)
+ end
+ Dir[File.join 'outbox', 'create', '*'].each do |create_file|
+ create = JSON.load_file(create_file)
+ next unless create['object']['id'] == id
- object = JSON.load_file(file)
- outbox 'Delete', object, object['to']
- FileUtils.rm(create_file)
- end
+ object = JSON.load_file(file)
+ outbox 'Delete', object, object['to']
+ FileUtils.rm(create_file)
end
+ # end
FileUtils.rm(file) if File.exist? file
end
200
@@ -45,6 +45,12 @@ post '/unfollow' do
params['id'] = actor params['mention'] if params['mention']
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']
+ }
outbox 'Undo', activity, [params['id']]
update_collection FOLLOWING, params['id'], true
200