From bd7e17e927824461c1af167fae292906b6212894 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 17 Jul 2023 21:58:43 +0200 Subject: threads fixed(?) --- client.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'client.rb') diff --git a/client.rb b/client.rb index 386175d..3ee3a7e 100644 --- a/client.rb +++ b/client.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # client-server -post '/' do +post '/' do # TODO protected! Time.now.strftime('%Y-%m-%dT%H:%M:%S.%N') @@ -86,7 +86,7 @@ post '/unfollow' do redirect(params['anchor'] || '/inbox') end -post '/share' do +post '/share' do # TODO protected! selection(params).each { |f| FileUtils.mv f, f.sub(%r{/inbox/}, '/shared/') } outbox 'Announce', params['id'], public @@ -112,15 +112,12 @@ end 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 - end + @threads << object if object['inReplyTo'].nil? || collection.select { |o| o['id'] == object['inReplyTo'] }.empty? + end + collection.each do |object| + collection.select { |o| o['id'] == object['inReplyTo'] }.each do |o| + object['indent'] = o['indent'] + 2 + o['replies'] << object end end erb :collection -- cgit v1.2.3