From eddcb71fcba716f85cbb442f93d462eeffb399ea Mon Sep 17 00:00:00 2001 From: maxwell Date: Sun, 24 Oct 2010 18:21:01 -0700 Subject: [PATCH] EM websocket cleanly merged with master. webfingering is now async --- app/controllers/requests_controller.rb | 3 +- config/deploy.rb | 1 - lib/em-webfinger.rb | 3 ++ spec/controllers/requests_controller_spec.rb | 3 ++ spec/lib/em-webfinger_spec.rb | 13 ++++++++ spec/models/person_spec.rb | 32 +++++++++++++++++++- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 409d9d417..a6dac609e 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -67,5 +67,4 @@ class RequestsController < ApplicationController return end end - end - +end diff --git a/config/deploy.rb b/config/deploy.rb index c721d82d8..09d8c0bc3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -134,7 +134,6 @@ namespace :db do task :tom_seed, :roles => :tom do run "cd #{current_path} && bundle exec rake db:seed:tom --trace RAILS_ENV=#{rails_env}" run "curl -silent -u tom@tom.joindiaspora.com:evankorth http://tom.joindiaspora.com/zombiefriends" - sleep(20) backers.each do |backer| run "curl -silent -u #{backer['username']}@#{backer['username']}.joindiaspora.com:#{backer['username']}#{backer['pin']} http://#{backer['username']}.joindiaspora.com/zombiefriendaccept" #run "curl -silent -u #{backer['username']}@#{backer['username']}.joindiaspora.com:#{backer['username']}#{backer['pin']} http://#{backer['username']}.joindiaspora.com/set_profile_photo" diff --git a/lib/em-webfinger.rb b/lib/em-webfinger.rb index 6b3d82326..6d2756a9a 100644 --- a/lib/em-webfinger.rb +++ b/lib/em-webfinger.rb @@ -14,6 +14,9 @@ class EMWebfinger def fetch raise 'you need to set a callback before calling fetch' if @callbacks.empty? + query = /\A^#{Regexp.escape(@account.gsub('acct:', '').to_s)}\z/i + local_person = Person.first(:diaspora_handle => query) + person = Person.by_account_identifier(@account) if person process_callbacks person diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index d0c409d14..cdafd8e1b 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -53,8 +53,11 @@ describe RequestsController do it 'should redirect to the page which you called it from ' do pending "i need to figure out how to do this" end +<<<<<<< HEAD it 'should not blow up if there is a problem mid way thru the webfinger process' do pending "i need to do this tomorrow end +======= +>>>>>>> EM websocket cleanly merged with master. webfingering is now async end diff --git a/spec/lib/em-webfinger_spec.rb b/spec/lib/em-webfinger_spec.rb index 76496e38d..cd4973b89 100644 --- a/spec/lib/em-webfinger_spec.rb +++ b/spec/lib/em-webfinger_spec.rb @@ -28,6 +28,10 @@ describe EMWebfinger do let(:non_diaspora_hcard) {File.open(File.join(Rails.root, 'spec/fixtures/evan_hcard')).read} context 'setup' do +<<<<<<< HEAD +======= + let(:action){ Proc.new{|person| puts person.inspect }} +>>>>>>> EM websocket cleanly merged with master. webfingering is now async describe '#intialize' do it 'sets account ' do @@ -36,6 +40,7 @@ describe EMWebfinger do end it 'should raise an error on an unresonable email' do +<<<<<<< HEAD proc{ EMWebfinger.new("joe.valid+email@my-address.com") }.should_not raise_error(RuntimeError, "Identifier is invalid") @@ -47,6 +52,10 @@ describe EMWebfinger do EMWebfinger.new('eviljoe@diaspora.local:3000') }.should raise_error(RuntimeError, "Identifier is invalid") end +======= + proc{EMWebfinger.new("asfadfasdf")}.should raise_error + end +>>>>>>> EM websocket cleanly merged with master. webfingering is now async end describe '#on_person' do @@ -112,6 +121,10 @@ describe EMWebfinger do } } end +<<<<<<< HEAD +======= + +>>>>>>> EM websocket cleanly merged with master. webfingering is now async end end end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index b2bfa0ab0..a1314281a 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -213,10 +213,40 @@ describe Person do f = Person.by_account_identifier("tom@tom.joindiaspora.com") f.should be nil end - end + describe '.local_by_account_identifier' do + it 'should find local users people' do + p = Person.local_by_account_identifier(user.diaspora_handle) + p.should == user.person + end + + + it 'identifier should be a valid email' do + pending "should check in the webfinger client" + stub_success("joe.valid+email@my-address.com") + Proc.new { + Person.by_account_identifier("joe.valid+email@my-address.com") + }.should_not raise_error(RuntimeError, "Identifier is invalid") + + stub_success("not_a_@valid_email") + Proc.new { + Person.by_account_identifer("not_a_@valid_email") + }.should raise_error(RuntimeError, "Identifier is invalid") + + end + + it 'should not accept a port number' do + pending "should check the webfinger client" + stub_success("eviljoe@diaspora.local:3000") + Proc.new { + Person.by_account_identifier('eviljoe@diaspora.local:3000') + }.should raise_error(RuntimeError, "Identifier is invalid") + end + + end + describe '.local_by_account_identifier' do it 'should find local users people' do p = Person.local_by_account_identifier(user.diaspora_handle)