diff --git a/Gemfile b/Gemfile index c3d8c3477f5ce8fdaf5a6142028cd35e3447e220..35958edae7fd0ac099c9c2314cdd4b6a93b79a03 100644 --- a/Gemfile +++ b/Gemfile @@ -29,6 +29,7 @@ gem 'json' #Standards gem 'pubsubhubbub' gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git' +gem 'prism' #EventMachine gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http' diff --git a/Gemfile.lock b/Gemfile.lock index d34538a54418a4e26c438a0d19fa21edac138abd..33e78e39b2ac9b167a130649eccef162809bac9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -152,6 +152,8 @@ GEM plucky (0.3.5) mongo (~> 1.0.8) polyglot (0.3.1) + prism (0.1.0) + nokogiri pubsubhubbub (0.1.1) em-http-request (>= 0.1.5) eventmachine (>= 0.12.9) @@ -242,6 +244,7 @@ DEPENDENCIES mongo_ext mongo_mapper (= 0.8.4)! nifty-generators + prism pubsubhubbub rails (= 3.0.0) redfinger! diff --git a/app/models/person.rb b/app/models/person.rb index 2f90fe7273cae101ab2f5e37ce819f91c04855b0..541dd03ebdad2fd6f340b5354d133a786173e0de 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -88,17 +88,24 @@ class Person end def self.from_webfinger_profile( identifier, profile) - public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href new_person = Person.new + + public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href new_person.exported_key = Base64.decode64 public_key + new_person.email = identifier + + puts profile.hcard.first[:href] + + hcard = Prism.find profile.hcard.first[:href] + puts hcard.inspect receive_url = profile.links.select{ |l| l.rel == 'http://joindiaspora.com/seed_location'}.first.href new_person.url = receive_url.split('receive').first new_person.profile = Profile.new(:first_name => "Anon", :last_name => "ymous") - if new_person.save! + if new_person.save new_person else - cry + nil end end diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index adeb2d2dbd1001ecb3197dafb9e9707bd509601c..f05590ea9122d3d380eb52087c66c5ecbc627e34 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <Subject>acct:<%=@person.email%></Subject> - <Alias>"<%= @person.url %>users/#{@user.id}/hcard"</Alias> - <Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>hcard"/> + <Alias>"<%= @person.url %>"</Alias> + <Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@person.url%>/hcard/users/<%=@person.id%>"/> <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.url%>status_messages.atom"/> <Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@person.receive_url%>"/> <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/> diff --git a/config/routes.rb b/config/routes.rb index 5e7a6eafcac015aa2bd4ec8351cae3c7125f7e73..43149ba57b178e457de8c5c7d3a795658f0ea6fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,7 +27,7 @@ Diaspora::Application.routes.draw do #public routes # match 'webfinger', :to => 'publics#webfinger' - match 'users/:id/hcard', :to => 'publics#hcard' + match 'hcard/users/:id', :to => 'publics#hcard' match '.well-known/host-meta',:to => 'publics#host_meta' match 'receive/users/:id', :to => 'publics#receive' diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 319e2b95659b9b60b2fc64b55d95c58c353fce7c..d2ce88049cc53922c0ac951d95ed92451f846dab 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -144,6 +144,12 @@ describe Person do it 'should search by email exactly' do Person.by_webfinger(@friend_one.email).should == @friend_one end + + it 'should create a stub for a remote user' do + tom = Person.by_webfinger('tom@tom.joindiaspora.com') + puts tom.real_name + tom.real_name.include?("Hamiltom").should be true + end describe 'wall posting' do it 'should be able to post on another persons wall' do