Loading Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ * 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) * 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 * Precompile facebox images [#6105](https://github.com/diaspora/diaspora/pull/6105) Loading app/models/person.rb +19 −13 Original line number Diff line number Diff line Loading @@ -204,25 +204,21 @@ class Person < ActiveRecord::Base end def url uri = URI.parse(self[:url]) url = "#{uri.scheme}://#{uri.host}" url += ":#{uri.port}" unless %w(80 443).include?(uri.port.to_s) url += "/" url url_to "/" rescue self[:url] end def profile_url "#{url}u/#{username}" url_to "/u/#{username}" end def atom_url "#{url}public/#{username}.atom" url_to "/public/#{username}.atom" end def receive_url "#{url}receive/users/#{guid}" url_to "/receive/users/#{guid}" end def public_key_hash Loading Loading @@ -321,11 +317,9 @@ class Person < ActiveRecord::Base # @param person [Person] # @param url [String] def update_url(url) location = URI.parse(url) newuri = "#{location.scheme}://#{location.host}" newuri += ":#{location.port}" unless ["80", "443"].include?(location.port.to_s) newuri += "/" self.update_attributes(:url => newuri) @uri = URI.parse(url) @uri.path = "/" update_attributes(:url => @uri.to_s) end def lock_access! Loading @@ -349,6 +343,18 @@ class Person < ActiveRecord::Base 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 Webfinger.new(self.diaspora_handle).fetch self.reload Loading spec/workers/http_multi_spec.rb +2 −4 Original line number Diff line number Diff line Loading @@ -110,8 +110,7 @@ describe Workers::HttpMulti do it 'updates http users who have moved to https' do person = @people.first person.url = 'http://remote.net/' person.save person.update_url("http://remote.net/") response = Typhoeus::Response.new( code: 301, Loading @@ -123,8 +122,7 @@ describe Workers::HttpMulti do Typhoeus.stub(person.receive_url).and_return response Workers::HttpMulti.new.perform bob.id, @post_xml, [person.id], "Postzord::Dispatcher::Private" person.reload expect(person.url).to eq("https://remote.net/") expect(Person.find(person.id).url).to eq("https://remote.net/") end it 'only sends to users with valid RSA keys' do Loading Loading
Changelog.md +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ * 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) * 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 * Precompile facebox images [#6105](https://github.com/diaspora/diaspora/pull/6105) Loading
app/models/person.rb +19 −13 Original line number Diff line number Diff line Loading @@ -204,25 +204,21 @@ class Person < ActiveRecord::Base end def url uri = URI.parse(self[:url]) url = "#{uri.scheme}://#{uri.host}" url += ":#{uri.port}" unless %w(80 443).include?(uri.port.to_s) url += "/" url url_to "/" rescue self[:url] end def profile_url "#{url}u/#{username}" url_to "/u/#{username}" end def atom_url "#{url}public/#{username}.atom" url_to "/public/#{username}.atom" end def receive_url "#{url}receive/users/#{guid}" url_to "/receive/users/#{guid}" end def public_key_hash Loading Loading @@ -321,11 +317,9 @@ class Person < ActiveRecord::Base # @param person [Person] # @param url [String] def update_url(url) location = URI.parse(url) newuri = "#{location.scheme}://#{location.host}" newuri += ":#{location.port}" unless ["80", "443"].include?(location.port.to_s) newuri += "/" self.update_attributes(:url => newuri) @uri = URI.parse(url) @uri.path = "/" update_attributes(:url => @uri.to_s) end def lock_access! Loading @@ -349,6 +343,18 @@ class Person < ActiveRecord::Base 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 Webfinger.new(self.diaspora_handle).fetch self.reload Loading
spec/workers/http_multi_spec.rb +2 −4 Original line number Diff line number Diff line Loading @@ -110,8 +110,7 @@ describe Workers::HttpMulti do it 'updates http users who have moved to https' do person = @people.first person.url = 'http://remote.net/' person.save person.update_url("http://remote.net/") response = Typhoeus::Response.new( code: 301, Loading @@ -123,8 +122,7 @@ describe Workers::HttpMulti do Typhoeus.stub(person.receive_url).and_return response Workers::HttpMulti.new.perform bob.id, @post_xml, [person.id], "Postzord::Dispatcher::Private" person.reload expect(person.url).to eq("https://remote.net/") expect(Person.find(person.id).url).to eq("https://remote.net/") end it 'only sends to users with valid RSA keys' do Loading