From 36c911d20b6b790e8f029b1552ae53dbd2968f3d Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 16 Jul 2010 21:33:08 -0700 Subject: [PATCH 1/5] IZ MS added diaspora rel to webfinger profile --- Gemfile | 2 +- app/controllers/requests_controller.rb | 13 +++++++++++++ app/views/publics/webfinger.erb | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index d40e7b65f..8e2c75d59 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'addressable', :require => "addressable/uri" gem 'em-websocket' gem 'thin' gem 'will_paginate', '3.0.pre' - +gem 'redfinger' group :test do gem 'rspec', '>= 2.0.0.beta.17' diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index c37a86ca7..069d3cb01 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -25,6 +25,7 @@ class RequestsController < ApplicationController end def create + url = find_url(params) @request = current_user.send_friend_request_to(params[:request][:destination_url]) if @request flash[:notice] = "a friend request was sent to #{@request.destination_url}" @@ -37,5 +38,17 @@ class RequestsController < ApplicationController end end + private + + def diasproa_url(url) + if url.include? '@' + f = Redfinger.finger(uri) + + end + + uri + end + + end diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index 8ad41e0e7..7814affc2 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -4,4 +4,5 @@ "<%=@user.url%>hcard" + hcard" - diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb deleted file mode 100644 index f9e91dad7..000000000 --- a/spec/controllers/request_controller_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -describe 'webfinger' do - redner_views - - describe "profile" do - it 'should fetch the public webfinger profile on request' do - post - end - end -end diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb index ce21cdc6b..03824a70b 100644 --- a/spec/controllers/requests_controller_spec.rb +++ b/spec/controllers/requests_controller_spec.rb @@ -1,11 +1,16 @@ -require 'spec_helper' +require File.dirname(__FILE__) + '/../spec_helper' describe RequestsController do - redner_views - describe "profile" do it 'should fetch the public webfinger profile on request' do - post + #post :create {:request => {:destination_url => 'tom@tom.joindiaspora.com'} + + url = RequestsController.diaspora_url('http://tom.joindiasproa.com') + url.should == 'htto://tom.joindiaspora.com' + + + url = RequestsController.diaspora_url('tom@tom.joindiaspora.com') + url.should == 'http://tom.joindiaspora.com' end end end From cd31d11aca1a155c4f05160401edc583c95ebf02 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 16 Jul 2010 22:11:38 -0700 Subject: [PATCH 4/5] MS IZ adding a friend through the webfinger profile --- app/controllers/requests_controller.rb | 11 ++--------- app/helpers/requests_helper.rb | 2 +- spec/helpers/requests_helper_spec.rb | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 spec/helpers/requests_helper_spec.rb diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index e986d6bcf..853cfc59d 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -25,8 +25,8 @@ class RequestsController < ApplicationController end def create - url = find_url(params) - @request = current_user.send_friend_request_to(params[:request][:destination_url]) + url = find_url(params[:request][:destination_url]) + @request = current_user.send_friend_request_to(url) if @request flash[:notice] = "a friend request was sent to #{@request.destination_url}" redirect_to requests_url @@ -39,13 +39,6 @@ class RequestsController < ApplicationController end - def self.diasproa_url(identifier) - if identifier.include? '@' - f = Redfinger.finger(uri) - identifier = f.each{|x| return x.link if x.rel =='http://joindiaspora.com/seed_location'} - end - identifier - end private diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index afafca44b..c0bf4a1d8 100644 --- a/app/helpers/requests_helper.rb +++ b/app/helpers/requests_helper.rb @@ -2,7 +2,7 @@ module RequestsHelper def diaspora_url(identifier) if identifier.include? '@' f = Redfinger.finger(identifier) - identifier = f.each{|x| return x.link if x.rel =='http://joindiaspora.com/seed_location'} + identifier = f.links.each{|x| return x.href if x.rel =='http://joindiaspora.com/seed_location'} end identifier end diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb new file mode 100644 index 000000000..38d0d1cd4 --- /dev/null +++ b/spec/helpers/requests_helper_spec.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +include RequestsHelper + +describe RequestsHelper do + describe "profile" do + it 'should fetch the public webfinger profile on request' do + #post :create {:request => {:destination_url => 'tom@tom.joindiaspora.com'} + + url = diaspora_url('http://tom.joindiaspora.com/') + url.should == 'http://tom.joindiaspora.com/' + + + url = diaspora_url('tom@tom.joindiaspora.com') + url.should == 'http://tom.joindiaspora.com/' + end + end +end From 44b4defb699c700fc9ffb134e02d973cfef53bd4 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 16 Jul 2010 22:20:25 -0700 Subject: [PATCH 5/5] MS IZ YEAAAAAAAAAAAAHHHHHgit push origin master git push origin master --- app/controllers/requests_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 853cfc59d..810b850f1 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -25,7 +25,7 @@ class RequestsController < ApplicationController end def create - url = find_url(params[:request][:destination_url]) + url = diaspora_url(params[:request][:destination_url]) @request = current_user.send_friend_request_to(url) if @request flash[:notice] = "a friend request was sent to #{@request.destination_url}"