summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/client.rb b/client.rb
index c2c64ea..24d8795 100644
--- a/client.rb
+++ b/client.rb
@@ -64,7 +64,12 @@ end
post '/delete' do
protected!
- selection(params).each { |f| FileUtils.rm f }
+ collection = Kernel.const_get(params['dir'].upcase)
+ if params['id']
+ update_collection collection, params, true
+ else
+ update_collection collection, JSON.parse(File.read(collection))['orderedItems'], true
+ end
redirect(params['anchor'] || '/inbox')
end
@@ -78,6 +83,8 @@ 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]
@@ -100,17 +107,24 @@ end
get path, provides: 'html' do
protected!
@dir = path.sub('/', '')
- collection = ordered_collection(File.join(SOCIAL_DIR, path, 'note'))['orderedItems']
+ # 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_with_index do |object, _idx|
+ collection.each do |object|
object['indent'] = 0
object['replies'] = []
if object['inReplyTo'].nil? || collection.select { |o| o['id'] == object['inReplyTo'] }.empty?
@threads << object
else
collection.select { |o| o['id'] == object['inReplyTo'] }.each do |o|
+ next unless o['indent']
+
object['indent'] = o['indent'] + 2
o['replies'] << object
+ # else
+ # p o
end
end
end