diff options
author | pdp8 <pdp8@pdp8.info> | 2024-02-01 12:23:31 +0100 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2024-02-01 12:23:31 +0100 |
commit | 4586c63bd86fe3dad403086b15d5b74b6d67fc92 (patch) | |
tree | 41387860e635820738f27071a2d668212d1774d7 /server.rb | |
parent | 17fe7f0d25bc99285ddc3dbc153f1f3af9dca335 (diff) |
general outbox routes
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 |