From 0f039c1b813653869033e961810942f479a28685 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 24 Jul 2023 17:34:43 +0200 Subject: public outbox, inbox/outbox threads --- server.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'server.rb') diff --git a/server.rb b/server.rb index f337820..666b59e 100644 --- a/server.rb +++ b/server.rb @@ -24,19 +24,30 @@ get '/' do redirect 'https://pdp8.info' end +get '/outbox' do + files = Dir[File.join('outbox', 'create', '*.json')] + Dir[File.join('outbox', 'announce', '*.json')] + activities = files.collect { |f| JSON.parse(File.read(f)) } + ids = activities.sort_by { |a| a['published'] }.collect { |a| a['id'] } + { '@context' => 'https://www.w3.org/ns/activitystreams', + 'id' => 'https://social.pdp8.info/outbox', + 'type' => 'OrderedCollection', + 'totalItems' => ids.size, + 'orderedItems' => ids }.to_json +end + get '/pdp8', provides: 'html' do redirect 'https://pdp8.info' end +get '/pdp8' do + send_file(File.join(PUBLIC_DIR, 'pdp8.json'), type: CONTENT_TYPE) +end + get '/.well-known/webfinger' do halt 404 unless request['resource'] == "acct:#{MENTION}" send_file(WEBFINGER, type: 'application/jrd+json') end -get '/pdp8' do - send_file(File.join(PUBLIC_DIR, 'pdp8.json'), type: CONTENT_TYPE) -end - ['/following', '/followers'].each do |path| get path do send_file(File.join(PUBLIC_DIR, path) + '.json', type: CONTENT_TYPE) -- cgit v1.2.3