diff options
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 38 |
1 files changed, 28 insertions, 10 deletions
@@ -20,8 +20,20 @@ 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' + erb :outbox +end + get '/outbox', provides: 'html' do - @activities = public_outbox + redirect 'https://social.pdp8.info/outbox/create' erb :outbox end @@ -35,7 +47,7 @@ get '/outbox' do end get '/pdp8', provides: 'html' do - redirect 'https://social.pdp8.info/outbox' + redirect 'https://social.pdp8.info/outbox/create' end get '/pdp8' do @@ -158,14 +170,20 @@ 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| + 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 = 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 - announce = Dir[File.join('outbox', 'announce', '*.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 - create + announce + create_outbox + announce_outbox end # https://github.com/mastodon/mastodon/blob/main/app/controllers/concerns/signature_verification.rb @@ -220,6 +238,6 @@ helpers do # p signature puts comparison # jj @activity - # halt 403 + halt 403 end end |