diff options
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 24 |
1 files changed, 6 insertions, 18 deletions
@@ -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 |