diff options
author | pdp8 <pdp8@pdp8.info> | 2023-09-14 14:02:15 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-09-14 14:02:15 +0200 |
commit | eea88e8022d3fd3c46401e1a297ebd7318c3c7b1 (patch) | |
tree | 72a6ea1a1f07cbe13abd3eca2ece7b19a248a610 /server.rb | |
parent | d635057cb576c5570c5ceba5945cc5339b0f41ab (diff) |
send/digest fixed
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 32 |
1 files changed, 24 insertions, 8 deletions
@@ -17,13 +17,16 @@ end # public get '/' do - redirect 'https://pdp8.info' + redirect 'https://social.pdp8.info/outbox' +end + +get '/outbox', provides: 'html' do + @activities = public_outbox + erb :outbox end get '/outbox' do - files = Dir[File.join('outbox', 'create', '*.json')] + Dir[File.join('outbox', 'announce', '*.json')] - activities = files.collect { |f| JSON.load_file(f) } - ids = activities.sort_by { |a| a['published'] }.collect { |a| a['id'] } + ids = public_outbox.collect { |a| a['id'] } { '@context' => 'https://www.w3.org/ns/activitystreams', 'id' => 'https://social.pdp8.info/outbox', 'type' => 'OrderedCollection', @@ -32,7 +35,7 @@ get '/outbox' do end get '/pdp8', provides: 'html' do - redirect 'https://pdp8.info' + redirect 'https://social.pdp8.info/outbox' end get '/pdp8' do @@ -99,7 +102,7 @@ helpers do update_collection FOLLOWERS, @activity['object']['actor'], 'delete' when 'Create', 'Announce' file = find_file @activity['object']['object'] - FileUtils.rm(file) if file + FileUtils.rm(file) if file and File.exist? file else p "Cannot undo @activity['object']['type']" jj @activity @@ -109,13 +112,13 @@ helpers do def update file = find_file(@activity['object']['id']) - FileUtils.rm(file) if file + FileUtils.rm(file) if file and File.exist? file create end def delete file = find_file(@activity['object']['id']) - FileUtils.rm(file) if file + FileUtils.rm(file) if file and File.exist? file end def move @@ -151,6 +154,19 @@ helpers do File.open(File.join(INBOX[:dir], 'visited'), 'a+') { |f| f.puts @object['id'] } end + def public_outbox + # files = Dir[File.join('outbox', 'create', '*.json')] + Dir[File.join('outbox', 'announce', '*.json')] + 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 + # activities = files.collect { |f| JSON.load_file(f) } + # activities.select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }.sort_by { |a| a['published'] } + create + announce + end + # https://github.com/mastodon/mastodon/blob/main/app/controllers/concerns/signature_verification.rb def verify! # digest |