From 4586c63bd86fe3dad403086b15d5b74b6d67fc92 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Thu, 1 Feb 2024 12:23:31 +0100 Subject: general outbox routes --- server.rb | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'server.rb') diff --git a/server.rb b/server.rb index 94729cc..61cbe3c 100644 --- a/server.rb +++ b/server.rb @@ -18,15 +18,9 @@ get '/' do redirect 'https://social.pdp8.info/outbox' end -get '/outbox/announce', provides: 'html' do - @objects = announce_outbox.collect { |a| a['object'] } - @type = 'announce' - erb :outbox -end - -get '/outbox/create', provides: 'html' do - @objects = create_outbox.collect { |a| a['object'] } - @type = 'create' +get '/outbox/:activity', provides: 'html' do + @activity = params['activity'] + @objects = outbox(@activity).collect { |a| a['object'] } erb :outbox end @@ -167,20 +161,14 @@ helpers do File.open(File.join(INBOX[:dir], 'visited'), 'a+') { |f| f.puts @object['id'] } end - def create_outbox - Dir[File.join('outbox', 'create', '*.json')].collect do |f| - JSON.load_file(f) - end.select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }.sort_by { |a| a['published'] }.reverse - end - - def announce_outbox - Dir[File.join('outbox', 'announce', '*.json')].collect do |f| + def outbox(activity) + Dir[File.join('outbox', activity, '*.json')].collect do |f| JSON.load_file(f) end.select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }.sort_by { |a| a['published'] }.reverse end def public_outbox - create_outbox + announce_outbox + outbox('create') + outbox('announce') end # https://github.com/mastodon/mastodon/blob/main/app/controllers/concerns/signature_verification.rb -- cgit v1.2.3