From e4e4dedf8ca423e110787657799137444ca0f8fe Mon Sep 17 00:00:00 2001 From: pdp8 Date: Sat, 10 Feb 2024 00:09:34 +0100 Subject: outbox moved to website --- server.rb | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'server.rb') diff --git a/server.rb b/server.rb index 61cbe3c..0d92f8c 100644 --- a/server.rb +++ b/server.rb @@ -19,14 +19,11 @@ get '/' do end get '/outbox/:activity', provides: 'html' do - @activity = params['activity'] - @objects = outbox(@activity).collect { |a| a['object'] } - erb :outbox + redirect "https://pdp8.info/social/#{params['activity']}.html" end get '/outbox', provides: 'html' do - redirect 'https://social.pdp8.info/outbox/create' - erb :outbox + redirect 'https://pdp8.info/social/create.html' end get '/outbox' do @@ -39,7 +36,7 @@ get '/outbox' do end get '/pdp8', provides: 'html' do - redirect 'https://social.pdp8.info/outbox/create' + redirect 'https://pdp8.info/social/create.html' end get '/pdp8' do @@ -82,7 +79,10 @@ helpers do end def like - announce + @object ||= @activity['object'] + @object = fetch(@object) if @object.is_a? String and @object.match(/^http/) + @object['like'] = @activity['actor'] if @object + create end def follow @@ -153,12 +153,19 @@ helpers do @object = fetch(@object) if @object.is_a? String and @object.match(/^http/) return unless @object - if @activity['type'] != 'Update' && (@object['id'] and File.readlines(VISITED, chomp: true).include? @object['id']) - return + + # if @activity['type'] != 'Update' && (@object['id'] and File.readlines(VISITED, chomp: true).include? @object['id']) + # return + # end + if @object['id'] and File.readlines(VISITED, chomp: true).include? @object['id'] + return unless @activity['type'] = 'Update' + + FileUtils.rm_f find_object(@object['id'])[0] + end save_item @object, File.join(INBOX[:dir], 'object', @object['type'].downcase, activity_name) - File.open(File.join(INBOX[:dir], 'visited'), 'a+') { |f| f.puts @object['id'] } + File.open(VISITED, 'a+') { |f| f.puts @object['id'] } end def outbox(activity) -- cgit v1.2.3