diff --git a/Gemfile b/Gemfile index e3813ce4da41178a8b6c14240a01d04428bfd1e0..c2e6e3300c747dde8ebee57453b14decdbdc375d 100644 --- a/Gemfile +++ b/Gemfile @@ -28,6 +28,9 @@ gem 'pubsubhubbub' gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http' gem 'addressable', :require => 'addressable/uri' gem 'em-websocket' +gem 'thin' +gem 'will_paginate', '3.0.pre' +gem 'redfinger' #File uploading gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index c37a86ca7ebd7312f087bc17e13e1ce41e6340e9..810b850f1aad10604857959e76c309d8e5dfad62 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -25,7 +25,8 @@ class RequestsController < ApplicationController end def create - @request = current_user.send_friend_request_to(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}" redirect_to requests_url @@ -38,4 +39,8 @@ class RequestsController < ApplicationController end + + private + + end diff --git a/app/helpers/requests_helper.rb b/app/helpers/requests_helper.rb index 53ac95cccd2c829f4b729a96d1d9d220aeac0d99..c0bf4a1d8bf4432a4e5da25d17e844dbd687cb68 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.links.each{|x| return x.href 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 8ad41e0e7407d58ca618b7b70f785f7ccbc9864a..bafd58acb56e5d6e8a2cf6f5f8ae479efeaf0398 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -4,4 +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/seed_location" type = 'text/html' href="<%=@user.url%>"/> </XRD> diff --git a/spec/controllers/requests_controller_spec.rb b/spec/controllers/requests_controller_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..03824a70b5b92be068315680aea38916b1cea573 --- /dev/null +++ b/spec/controllers/requests_controller_spec.rb @@ -0,0 +1,16 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe RequestsController do + describe "profile" do + it 'should fetch the public webfinger profile on request' do + #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 diff --git a/spec/helpers/requests_helper_spec.rb b/spec/helpers/requests_helper_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..38d0d1cd44edaaa35741ad61099d9f1155444f28 --- /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 diff --git a/spec/models/webfinger_spec.rb b/spec/models/webfinger_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..9969a5f389d8b35795a127a3a159ec66a48d0745 --- /dev/null +++ b/spec/models/webfinger_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe 'webfinger' do + redner_views + describe "profile" do + it 'should fetch the public webfinger profile on request' do + + end + end +end