summaryrefslogtreecommitdiff
path: root/server.rb
diff options
context:
space:
mode:
Diffstat (limited to 'server.rb')
-rw-r--r--server.rb27
1 files changed, 17 insertions, 10 deletions
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)