diff options
author | pdp8 <pdp8@pdp8.info> | 2024-02-10 00:09:34 +0100 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2024-02-10 00:09:34 +0100 |
commit | e4e4dedf8ca423e110787657799137444ca0f8fe (patch) | |
tree | d3bd95af4c58e76ca97b961f6e03e28376d8d6bb /server.rb | |
parent | 4586c63bd86fe3dad403086b15d5b74b6d67fc92 (diff) |
outbox moved to website
Diffstat (limited to 'server.rb')
-rw-r--r-- | server.rb | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -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) |