diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb index acbe5e814..3c7a2af8f 100644 --- a/app/controllers/publics_controller.rb +++ b/app/controllers/publics_controller.rb @@ -3,8 +3,11 @@ class PublicsController < ApplicationController include Diaspora::Parser def hcard - @user = User.owner - render 'hcard' + @person = Person.first(:_id => params[:id]) + + unless @person.nil? || @person.owner.nil? + render 'hcard' + end end def host_meta @@ -13,8 +16,10 @@ class PublicsController < ApplicationController end def webfinger - @user = Person.first(:email => params[:q].gsub('acct:', '')) - render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' + @person = Person.first(:email => params[:q].gsub('acct:', '')) + unless @person.nil? || @person.owner.nil? + render 'webfinger', :layout => false, :content_type => 'application/xrd+xml' + end end def receive diff --git a/app/helpers/publics_helper.rb b/app/helpers/publics_helper.rb index e694adef9..1e8ecac8f 100644 --- a/app/helpers/publics_helper.rb +++ b/app/helpers/publics_helper.rb @@ -14,4 +14,11 @@ module PublicsHelper 400 end end -end \ No newline at end of file + + def terse_url(full_url) + terse = full_url.gsub(/https?:\/\//, '') + terse.gsub!(/www\./, '') + terse = terse.chop! if terse[-1, 1] == '/' + terse + end +end diff --git a/app/models/person.rb b/app/models/person.rb index f633d04c7..3eaebd8d2 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -109,6 +109,9 @@ class Person self.id == post.person.id end + def recieve_url + "#{self.url}user/#{self.owner.id}" + end protected def clean_url diff --git a/app/models/user.rb b/app/models/user.rb index 43fc0c279..df7483c22 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,14 +77,11 @@ class User def receive_friend_request(friend_request) Rails.logger.debug("receiving friend request #{friend_request.to_json}") - #u am originator if Request.where(:callback_url => person.url, :destination_url => person.url).first - puts "NOOO!!" activate_friend friend_request.person Rails.logger.debug("#{self.real_name}'s friend request has been accepted") friend_request.destroy else - puts "423423" friend_request.person.save pending_requests << friend_request save diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index 34f88866e..7cfbe5604 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -1,24 +1,24 @@
-

<%=@user.real_name%>

+

<%=@person.real_name%>

User profile

Nickname
- <%= @user.real_name%> + <%= @person.real_name%>
Full name
- <%= @user.real_name %> + <%= @person.real_name %>
URL
- <%= @user.url%> + <%= @person.url%>
diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index 53d8aeba4..e28fb6211 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ - <%= @user.terse_url %> + <%= terse_url(root_url) %> + template='<%= root_url %>webfinger?q={uri}'> Resource Descriptor diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index bafd58acb..db4cd3a1c 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,8 +1,8 @@ - acct:<%=@user.email%> - "<%=@user.url%>hcard" - - - + acct:<%=@person.email%> + "<%= @person.url %>users/#{@user.id}/hcard" + + + diff --git a/config/routes.rb b/config/routes.rb index 50811fa73..7e830ecc5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,13 +24,13 @@ Diaspora::Application.routes.draw do |map| #match 'signup', :to => 'devise/registrations#new', :as => "new_user_registration" resources :users - #public routes - match 'receive/users/:id', :to => 'publics#receive' - match '.well-known/host-meta',:to => 'publics#host_meta' - match 'webfinger', :to => 'publics#webfinger' - match 'hcard', :to => 'publics#hcard' - + # + match 'webfinger', :to => 'publics#webfinger' + match 'users/:id/hcard', :to => 'publics#hcard' + + match '.well-known/host-meta',:to => 'publics#host_meta' + match 'receive/users/:id', :to => 'publics#receive' #root root :to => 'dashboards#index' end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 6fcd775d3..41046b932 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -4,6 +4,8 @@ describe Person do before do @person = Factory.create(:person) end + + it 'should not allow two people with the same email' do person_two = Factory.build(:person, :url => @person.email) person_two.valid?.should == false