From f34e033bce13b94cf4e778474d22dfcff882a221 Mon Sep 17 00:00:00 2001
From: maxwell <maxwell@joindiaspora.com>
Date: Fri, 16 Jul 2010 21:59:40 -0700
Subject: [PATCH] MS IZ getting the profile

---
 app/controllers/requests_controller.rb       | 11 +++++------
 app/helpers/requests_helper.rb               |  8 ++++++++
 app/views/publics/webfinger.erb              |  2 +-
 spec/controllers/request_controller_spec.rb  |  9 ---------
 spec/controllers/requests_controller_spec.rb | 13 +++++++++----
 5 files changed, 23 insertions(+), 20 deletions(-)
 delete mode 100644 spec/controllers/request_controller_spec.rb

diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb
index 03c56f4aa5..e986d6bcf6 100644
--- a/app/controllers/requests_controller.rb
+++ b/app/controllers/requests_controller.rb
@@ -23,7 +23,6 @@ class RequestsController < ApplicationController
   def new
     @request = Request.new
   end
-require 'spec_helper'
   
   def create
     url = find_url(params)
@@ -39,16 +38,16 @@ require 'spec_helper'
     end
   end
 
-  private 
 
-  def diasproa_url(url)
-    if url.include? '@'
+  def self.diasproa_url(identifier)
+    if identifier.include? '@'
       f = Redfinger.finger(uri)
-      url
+      identifier = f.each{|x|  return x.link if x.rel =='http://joindiaspora.com/seed_location'}
     end
-
+    identifier
   end
   
+  private 
 
 
 end
diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb
index 53ac95cccd..afafca44b5 100644
--- a/app/helpers/requests_helper.rb
+++ b/app/helpers/requests_helper.rb
@@ -1,2 +1,10 @@
 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'}
+    end
+    identifier
+  end
+
 end
diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb
index 7814affc23..bafd58acb5 100644
--- a/app/views/publics/webfinger.erb
+++ b/app/views/publics/webfinger.erb
@@ -4,5 +4,5 @@
   <Alias>"<%=@user.url%>hcard"</Alias>
   <Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@user.url%>hcard"/>
   <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@user.url%>status_messages.atom"/>
-  <Link rel="http://joindiaspora.com/location" type = 'text/html' href="<%=@user.url%>
+  <Link rel="http://joindiaspora.com/seed_location" type = 'text/html' href="<%=@user.url%>"/>
 </XRD>
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
deleted file mode 100644
index f9e91dad71..0000000000
--- 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 ce21cdc6b7..03824a70b5 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
-- 
GitLab