diff --git a/Gemfile b/Gemfile index c3d8c3477..35958edae 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 d34538a54..33e78e39b 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 2f90fe727..541dd03eb 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 adeb2d2db..f05590ea9 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,8 +1,8 @@ acct:<%=@person.email%> - "<%= @person.url %>users/#{@user.id}/hcard" - + "<%= @person.url %>" + diff --git a/config/routes.rb b/config/routes.rb index 5e7a6eafc..43149ba57 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 319e2b956..d2ce88049 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