Merge pull request #5659 from Zauberstuhl/link_to_remote_profile
Add the ability to link remote user profiles
This commit is contained in:
commit
84cfaa1cfb
3 changed files with 24 additions and 6 deletions
|
|
@ -184,13 +184,21 @@ class PeopleController < ApplicationController
|
|||
private
|
||||
|
||||
def find_person
|
||||
@person = Person.find_from_guid_or_username({
|
||||
id: params[:id] || params[:person_id],
|
||||
username: params[:username]
|
||||
})
|
||||
username = params[:username]
|
||||
@person = if diaspora_id?(username)
|
||||
Person.where({
|
||||
diaspora_handle: username.downcase
|
||||
}).first
|
||||
else
|
||||
Person.find_from_guid_or_username({
|
||||
id: params[:id] || params[:person_id],
|
||||
username: username
|
||||
})
|
||||
end
|
||||
|
||||
# view this profile on the home pod, if you don't want to sign in...
|
||||
authenticate_user! if remote_profile_with_no_user_session?
|
||||
raise ActiveRecord::RecordNotFound if @person.nil?
|
||||
raise Diaspora::AccountClosed if @person.closed_account?
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -175,8 +175,8 @@ Diaspora::Application.routes.draw do
|
|||
get :tag_index
|
||||
end
|
||||
end
|
||||
get '/u/:username' => 'people#show', :as => 'user_profile'
|
||||
get '/u/:username/profile_photo' => 'users#user_photo'
|
||||
get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ }
|
||||
get '/u/:username/profile_photo' => 'users#user_photo', :constraints => { :username => /[^\/]+/ }
|
||||
|
||||
|
||||
# Federation
|
||||
|
|
|
|||
|
|
@ -179,6 +179,16 @@ describe PeopleController, :type => :controller do
|
|||
expect(assigns(:person)).to eq(@user.person)
|
||||
end
|
||||
|
||||
it "404s if no person is found via diaspora handle" do
|
||||
get :show, :username => 'delicious@pod.net'
|
||||
expect(response.code).to eq("404")
|
||||
end
|
||||
|
||||
it 'finds a person via diaspora handle' do
|
||||
get :show, username: @user.diaspora_handle
|
||||
expect(assigns(:person)).to eq(@user.person)
|
||||
end
|
||||
|
||||
it 'redirects home for closed account' do
|
||||
@person = FactoryGirl.create(:person, :closed_account => true)
|
||||
get :show, :id => @person.to_param
|
||||
|
|
|
|||
Loading…
Reference in a new issue