MS IZ adding a friend through the webfinger profile

This commit is contained in:
maxwell 2010-07-16 22:11:38 -07:00
parent f34e033bce
commit cd31d11aca
3 changed files with 21 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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