Merge branch 'master' of github.com:diaspora/diaspora into production
This commit is contained in:
commit
1e646fb0a9
6 changed files with 20 additions and 6 deletions
|
|
@ -21,9 +21,11 @@ class PublicsController < ApplicationController
|
|||
end
|
||||
|
||||
def webfinger
|
||||
@person = Person.by_webfinger(params[:q])
|
||||
@person = Person.by_webfinger(params[:q], :local => true)
|
||||
unless @person.nil? || @person.owner.nil?
|
||||
render 'webfinger', :content_type => 'application/xrd+xml'
|
||||
else
|
||||
render :nothing => true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class RequestsController < ApplicationController
|
|||
begin
|
||||
rel_hash = relationship_flow(params[:request][:destination_url])
|
||||
rescue Exception => e
|
||||
raise e unless e.message.include? "not found"
|
||||
flash[:error] = "No diaspora seed found with this email!"
|
||||
respond_with :location => aspect
|
||||
return
|
||||
|
|
|
|||
|
|
@ -78,18 +78,18 @@ class Person
|
|||
@serialized_key = new_key
|
||||
end
|
||||
|
||||
def self.by_webfinger( identifier )
|
||||
def self.by_webfinger( identifier, opts = {})
|
||||
local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', ''))
|
||||
|
||||
if local_person
|
||||
local_person
|
||||
elsif !identifier.include?("localhost")
|
||||
elsif !identifier.include?("localhost") && !opts[:local]
|
||||
begin
|
||||
f = Redfinger.finger(identifier)
|
||||
rescue SocketError => e
|
||||
raise "Diaspora server for #{identifier} not found" if e.message =~ /Name or service not known/
|
||||
end
|
||||
raise "No webfinger profile found at #{identifier}" unless f
|
||||
raise "No webfinger profile found at #{identifier}" if f.nil? || f.links.empty?
|
||||
Person.from_webfinger_profile(identifier, f )
|
||||
end
|
||||
end
|
||||
|
|
@ -97,7 +97,11 @@ class Person
|
|||
def self.from_webfinger_profile( identifier, profile)
|
||||
new_person = Person.new
|
||||
|
||||
public_key = profile.links.select{|x| x.rel == 'diaspora-public-key'}.first.href
|
||||
public_key_entry = profile.links.select{|x| x.rel == 'diaspora-public-key'}
|
||||
|
||||
return nil unless public_key_entry
|
||||
|
||||
public_key = public_key_entry.first.href
|
||||
new_person.exported_key = Base64.decode64 public_key
|
||||
|
||||
guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ else
|
|||
|
||||
###Helpers############
|
||||
def self.instantiate!( opts = {} )
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}"
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{URI::parse(opts[:url]).host}"
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create!(opts)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ Diaspora::Application.routes.draw do
|
|||
match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session"
|
||||
match 'signup', :to => 'registrations#new', :as => "new_user_registration"
|
||||
|
||||
match 'get_to_the_choppa', :to => redirect("/signup")
|
||||
#public routes
|
||||
#
|
||||
match 'webfinger', :to => 'publics#webfinger'
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ describe PublicsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'webfinger' do
|
||||
it 'should not try to webfinger out on a request to webfinger' do
|
||||
Redfinger.should_not_receive :finger
|
||||
post :webfinger, :q => 'remote@example.com'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'friend requests' do
|
||||
before do
|
||||
|
|
|
|||
Loading…
Reference in a new issue