parent
97f973b80a
commit
b0a9a6342f
3 changed files with 22 additions and 17 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
* Update perfect-scrollbar [#6085](https://github.com/diaspora/diaspora/pull/6085)
|
* Update perfect-scrollbar [#6085](https://github.com/diaspora/diaspora/pull/6085)
|
||||||
* Remove top margin for first heading in a post [#6110](https://github.com/diaspora/diaspora/pull/6110)
|
* Remove top margin for first heading in a post [#6110](https://github.com/diaspora/diaspora/pull/6110)
|
||||||
* Add link to pod statistics in right navigation [#6117](https://github.com/diaspora/diaspora/pull/6117)
|
* Add link to pod statistics in right navigation [#6117](https://github.com/diaspora/diaspora/pull/6117)
|
||||||
|
* Refactor person related URL generation [#6168](https://github.com/diaspora/diaspora/pull/6168)
|
||||||
|
|
||||||
## Bug fixes
|
## Bug fixes
|
||||||
* Precompile facebox images [#6105](https://github.com/diaspora/diaspora/pull/6105)
|
* Precompile facebox images [#6105](https://github.com/diaspora/diaspora/pull/6105)
|
||||||
|
|
|
||||||
|
|
@ -204,25 +204,21 @@ class Person < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
uri = URI.parse(self[:url])
|
url_to "/"
|
||||||
url = "#{uri.scheme}://#{uri.host}"
|
|
||||||
url += ":#{uri.port}" unless %w(80 443).include?(uri.port.to_s)
|
|
||||||
url += "/"
|
|
||||||
url
|
|
||||||
rescue
|
rescue
|
||||||
self[:url]
|
self[:url]
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_url
|
def profile_url
|
||||||
"#{url}u/#{username}"
|
url_to "/u/#{username}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def atom_url
|
def atom_url
|
||||||
"#{url}public/#{username}.atom"
|
url_to "/public/#{username}.atom"
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_url
|
def receive_url
|
||||||
"#{url}receive/users/#{guid}"
|
url_to "/receive/users/#{guid}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_key_hash
|
def public_key_hash
|
||||||
|
|
@ -321,11 +317,9 @@ class Person < ActiveRecord::Base
|
||||||
# @param person [Person]
|
# @param person [Person]
|
||||||
# @param url [String]
|
# @param url [String]
|
||||||
def update_url(url)
|
def update_url(url)
|
||||||
location = URI.parse(url)
|
@uri = URI.parse(url)
|
||||||
newuri = "#{location.scheme}://#{location.host}"
|
@uri.path = "/"
|
||||||
newuri += ":#{location.port}" unless ["80", "443"].include?(location.port.to_s)
|
update_attributes(:url => @uri.to_s)
|
||||||
newuri += "/"
|
|
||||||
self.update_attributes(:url => newuri)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def lock_access!
|
def lock_access!
|
||||||
|
|
@ -349,6 +343,18 @@ class Person < ActiveRecord::Base
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# @return [URI]
|
||||||
|
def uri
|
||||||
|
@uri ||= URI.parse(self[:url])
|
||||||
|
@uri.dup
|
||||||
|
end
|
||||||
|
|
||||||
|
# @param path [String]
|
||||||
|
# @return [String]
|
||||||
|
def url_to(path)
|
||||||
|
uri.tap {|uri| uri.path = path }.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def fix_profile
|
def fix_profile
|
||||||
Webfinger.new(self.diaspora_handle).fetch
|
Webfinger.new(self.diaspora_handle).fetch
|
||||||
self.reload
|
self.reload
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,7 @@ describe Workers::HttpMulti do
|
||||||
|
|
||||||
it 'updates http users who have moved to https' do
|
it 'updates http users who have moved to https' do
|
||||||
person = @people.first
|
person = @people.first
|
||||||
person.url = 'http://remote.net/'
|
person.update_url("http://remote.net/")
|
||||||
person.save
|
|
||||||
|
|
||||||
response = Typhoeus::Response.new(
|
response = Typhoeus::Response.new(
|
||||||
code: 301,
|
code: 301,
|
||||||
|
|
@ -123,8 +122,7 @@ describe Workers::HttpMulti do
|
||||||
Typhoeus.stub(person.receive_url).and_return response
|
Typhoeus.stub(person.receive_url).and_return response
|
||||||
|
|
||||||
Workers::HttpMulti.new.perform bob.id, @post_xml, [person.id], "Postzord::Dispatcher::Private"
|
Workers::HttpMulti.new.perform bob.id, @post_xml, [person.id], "Postzord::Dispatcher::Private"
|
||||||
person.reload
|
expect(Person.find(person.id).url).to eq("https://remote.net/")
|
||||||
expect(person.url).to eq("https://remote.net/")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'only sends to users with valid RSA keys' do
|
it 'only sends to users with valid RSA keys' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue