summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-07-17 21:00:10 +0200
committerpdp8 <pdp8@pdp8.info>2023-07-17 21:00:10 +0200
commit8596528d9c0c07cc46279679f61729a3c06d902e (patch)
tree7fe1dd60cffddbe74488c360c119b87a5b125da1 /client.rb
parent4ca1c5555f18703d1dac673b1a77d1c919fb4787 (diff)
client (un)follow fixed
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb33
1 files changed, 14 insertions, 19 deletions
diff --git a/client.rb b/client.rb
index 24d8795..386175d 100644
--- a/client.rb
+++ b/client.rb
@@ -55,13 +55,6 @@ post '/' do
redirect(params['anchor'] || '/inbox')
end
-post '/share' do
- protected!
- selection(params).each { |f| FileUtils.mv f, f.sub(%r{/inbox/}, '/shared/') }
- outbox 'Announce', params['id'], public
- redirect(params['anchor'] || '/inbox')
-end
-
post '/delete' do
protected!
collection = Kernel.const_get(params['dir'].upcase)
@@ -83,14 +76,21 @@ end
post '/unfollow' do
protected!
actor, mention = parse_follow params['follow']
- outbox 'Undo', JSON.parse(File.read(following_path)), [actor]
- p actor
- following_path = File.join(FOLLOWING_DIR, "#{mention}.json")
- if File.exist?(following_path)
- outbox 'Undo', JSON.parse(File.read(following_path)), [actor]
- FileUtils.rm_f following_path
- redirect(params['anchor'] || '/inbox')
+ Dir[File.join(OUTBOX_DIR, 'follow', '*.json')].each do |f|
+ activity = JSON.parse(File.read(f))
+ if activity['object'] == actor
+ outbox 'Undo', activity, [actor]
+ update_collection FOLLOWING, actor, true
+ end
end
+ redirect(params['anchor'] || '/inbox')
+end
+
+post '/share' do
+ protected!
+ selection(params).each { |f| FileUtils.mv f, f.sub(%r{/inbox/}, '/shared/') }
+ outbox 'Announce', params['id'], public
+ redirect(params['anchor'] || '/inbox')
end
post '/login' do
@@ -107,10 +107,7 @@ end
get path, provides: 'html' do
protected!
@dir = path.sub('/', '')
- # p(Kernel.const_get(@dir.upcase))
- # p(File.read(Kernel.const_get(@dir.upcase)))
collection = JSON.parse(File.read(Kernel.const_get(@dir.upcase)))['orderedItems'].uniq
- # collection = ordered_collection(File.join(SOCIAL_DIR, path, 'note'))['orderedItems']
@threads = []
collection.each do |object|
object['indent'] = 0
@@ -123,8 +120,6 @@ end
object['indent'] = o['indent'] + 2
o['replies'] << object
- # else
- # p o
end
end
end