Merge branch 'stable' into develop
This commit is contained in:
commit
1e4224813e
15 changed files with 104 additions and 91 deletions
|
|
@ -51,6 +51,7 @@ bind to an UNIX socket at `unix:tmp/diaspora.sock`. Please change your local
|
||||||
* 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)
|
||||||
* Update to Rails 4.2.3 [#6140](https://github.com/diaspora/diaspora/pull/6140)
|
* Update to Rails 4.2.3 [#6140](https://github.com/diaspora/diaspora/pull/6140)
|
||||||
|
* 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)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ module LayoutHelper
|
||||||
|
|
||||||
def current_user_atom_tag
|
def current_user_atom_tag
|
||||||
return unless @person.present?
|
return unless @person.present?
|
||||||
content_tag(:link, '', :rel => 'alternate', :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => t('.public_feed', :name => @person.name))
|
content_tag(:link, "", rel: "alternate", href: @person.atom_url, type: "application/atom+xml",
|
||||||
|
title: t(".public_feed", name: @person.name))
|
||||||
end
|
end
|
||||||
|
|
||||||
def translation_missing_warnings
|
def translation_missing_warnings
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
# the COPYRIGHT file.
|
|
||||||
|
|
||||||
module PublicsHelper
|
|
||||||
def subscribe(opts = {})
|
|
||||||
subscriber = Subscriber.first(:url => opts[:callback], :topic => opts[:topic])
|
|
||||||
subscriber ||= Subscriber.new(:url => opts[:callback], :topic => opts[:topic])
|
|
||||||
|
|
||||||
if subscriber.save
|
|
||||||
if opts[:verify] == 'sync'
|
|
||||||
204
|
|
||||||
elsif opts[:verify] == 'async'
|
|
||||||
202
|
|
||||||
end
|
|
||||||
else
|
|
||||||
400
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -195,33 +195,30 @@ class Person < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def username
|
||||||
|
@username ||= owner ? owner.username : diaspora_handle.split("@")[0]
|
||||||
|
end
|
||||||
|
|
||||||
def owns?(obj)
|
def owns?(obj)
|
||||||
self.id == obj.author_id
|
self.id == obj.author_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def url
|
||||||
begin
|
url_to "/"
|
||||||
uri = URI.parse(self[:url])
|
rescue
|
||||||
url = "#{uri.scheme}://#{uri.host}"
|
self[:url]
|
||||||
url += ":#{uri.port}" unless ["80", "443"].include?(uri.port.to_s)
|
end
|
||||||
url += "/"
|
|
||||||
rescue => e
|
def profile_url
|
||||||
url = self[:url]
|
url_to "/u/#{username}"
|
||||||
end
|
end
|
||||||
url
|
|
||||||
|
def atom_url
|
||||||
|
url_to "/public/#{username}.atom"
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive_url
|
def receive_url
|
||||||
"#{url}receive/users/#{self.guid}/"
|
url_to "/receive/users/#{guid}"
|
||||||
end
|
|
||||||
|
|
||||||
def public_url
|
|
||||||
if self.owner
|
|
||||||
username = self.owner.username
|
|
||||||
else
|
|
||||||
username = self.diaspora_handle.split("@")[0]
|
|
||||||
end
|
|
||||||
"#{url}public/#{username}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def public_key_hash
|
def public_key_hash
|
||||||
|
|
@ -263,7 +260,6 @@ class Person < ActiveRecord::Base
|
||||||
#hcard_profile = HCard.find profile.hcard.first[:href]
|
#hcard_profile = HCard.find profile.hcard.first[:href]
|
||||||
::Logging::Logger[self].info "event=webfinger_marshal valid=#{new_person.valid?} " \
|
::Logging::Logger[self].info "event=webfinger_marshal valid=#{new_person.valid?} " \
|
||||||
"target=#{new_person.diaspora_handle}"
|
"target=#{new_person.diaspora_handle}"
|
||||||
new_person.url = hcard[:url]
|
|
||||||
new_person.assign_new_profile_from_hcard(hcard)
|
new_person.assign_new_profile_from_hcard(hcard)
|
||||||
new_person.save!
|
new_person.save!
|
||||||
new_person.profile.save!
|
new_person.profile.save!
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class User < ActiveRecord::Base
|
||||||
has_one :profile, through: :person
|
has_one :profile, through: :person
|
||||||
|
|
||||||
delegate :guid, :public_key, :posts, :photos, :owns?, :image_url,
|
delegate :guid, :public_key, :posts, :photos, :owns?, :image_url,
|
||||||
:diaspora_handle, :name, :public_url, :profile, :url,
|
:diaspora_handle, :name, :atom_url, :profile_url, :profile, :url,
|
||||||
:first_name, :last_name, :gender, :participations, to: :person
|
:first_name, :last_name, :gender, :participations, to: :person
|
||||||
delegate :id, :guid, to: :person, prefix: true
|
delegate :id, :guid, to: :person, prefix: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<Link rel="http://joindiaspora.com/guid" type = 'text/html' href="<%=@person.guid%>"/>
|
<Link rel="http://joindiaspora.com/guid" type = 'text/html' href="<%=@person.guid%>"/>
|
||||||
|
|
||||||
<Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%=person_href(@person, :absolute => true)%>/>
|
<Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%=person_href(@person, :absolute => true)%>/>
|
||||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/>
|
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.atom_url%>"/>
|
||||||
<Link rel="salmon" href="<%= @person.receive_url %>"/>
|
<Link rel="salmon" href="<%= @person.receive_url %>"/>
|
||||||
|
|
||||||
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.strict_encode64(@person.exported_key)%>"/>
|
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.strict_encode64(@person.exported_key)%>"/>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
= t(".title")
|
= t(".title")
|
||||||
.modal-body
|
.modal-body
|
||||||
%p=t('.outside')
|
%p=t('.outside')
|
||||||
%p= link_to t('.atom_feed'), "#{current_user.public_url}.atom"
|
%p= link_to t(".atom_feed"), current_user.atom_url
|
||||||
- if current_user.services
|
- if current_user.services
|
||||||
- for service in current_user.services
|
- for service in current_user.services
|
||||||
%p= t('.logged_in', :service => service.provider)
|
%p= t('.logged_in', :service => service.provider)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
|
atom_feed("xmlns:thr" => "http://purl.org/syndication/thread/1.0",
|
||||||
'xmlns:georss' => 'http://www.georss.org/georss',
|
"xmlns:georss" => "http://www.georss.org/georss",
|
||||||
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
|
"xmlns:activity" => "http://activitystrea.ms/spec/1.0/",
|
||||||
'xmlns:media' => 'http://purl.org/syndication/atommedia',
|
"xmlns:media" => "http://purl.org/syndication/atommedia",
|
||||||
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
|
"xmlns:poco" => "http://portablecontacts.net/spec/1.0",
|
||||||
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
|
"xmlns:ostatus" => "http://ostatus.org/schema/1.0",
|
||||||
'xmlns:statusnet' => 'http://status.net/schema/api/1/',
|
"xmlns:statusnet" => "http://status.net/schema/api/1/",
|
||||||
:id => "#{@user.public_url}.atom",
|
:id => @user.atom_url,
|
||||||
:root_url => "#{@user.public_url}"}) do |feed|
|
:root_url => @user.profile_url) do |feed|
|
||||||
|
|
||||||
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig.pod_uri.to_s}"
|
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig.pod_uri.to_s}"
|
||||||
feed.title "#{@user.name}'s Public Feed"
|
feed.title "#{@user.name}'s Public Feed"
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,8 @@ module Workers
|
||||||
class PublishToHub < Base
|
class PublishToHub < Base
|
||||||
sidekiq_options queue: :http_service
|
sidekiq_options queue: :http_service
|
||||||
|
|
||||||
def perform(sender_public_url)
|
def perform(sender_atom_url)
|
||||||
atom_url = sender_public_url + '.atom'
|
Pubsubhubbub.new(AppConfig.environment.pubsub_server.get).publish(sender_atom_url)
|
||||||
Pubsubhubbub.new(AppConfig.environment.pubsub_server.get).publish(atom_url)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,25 +4,19 @@
|
||||||
|
|
||||||
module Workers
|
module Workers
|
||||||
class PublishToHub < Base
|
class PublishToHub < Base
|
||||||
def perform(sender_public_url)
|
def perform(_sender_atom_url)
|
||||||
# don't publish to pubsubhubbub in cucumber
|
# don't publish to pubsubhubbub in cucumber
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class HttpMulti < Base
|
class HttpMulti < Base
|
||||||
def perform(user_id, enc_object_xml, person_ids, retry_count=0)
|
def perform(_user_id, _enc_object_xml, _person_ids, _retry_count=0)
|
||||||
# don't federate in cucumber
|
# don't federate in cucumber
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class HttpPost < Base
|
|
||||||
def perform(url, body, tries_remaining = NUM_TRIES)
|
|
||||||
# don't post to outside services in cucumber
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class PostToService < Base
|
class PostToService < Base
|
||||||
def perform(service_id, post_id, url)
|
def perform(_service_id, _post_id, _url)
|
||||||
# don't post to services in cucumber
|
# don't post to services in cucumber
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class Postzord::Dispatcher
|
||||||
|
|
||||||
def deliver_to_hub
|
def deliver_to_hub
|
||||||
logger.debug "event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}"
|
logger.debug "event=post_to_service type=pubsub sender_handle=#{@sender.diaspora_handle}"
|
||||||
Workers::PublishToHub.perform_async(@sender.public_url)
|
Workers::PublishToHub.perform_async(@sender.atom_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param url [String]
|
# @param url [String]
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ describe Postzord::Dispatcher do
|
||||||
|
|
||||||
it 'queues a job to notify the hub' do
|
it 'queues a job to notify the hub' do
|
||||||
allow(Workers::PostToService).to receive(:perform_async).with(anything, anything, anything)
|
allow(Workers::PostToService).to receive(:perform_async).with(anything, anything, anything)
|
||||||
expect(Workers::PublishToHub).to receive(:perform_async).with(alice.public_url)
|
expect(Workers::PublishToHub).to receive(:perform_async).with(alice.atom_url)
|
||||||
@zord.send(:deliver_to_services, nil, [])
|
@zord.send(:deliver_to_services, nil, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,20 +108,55 @@ describe Person, :type => :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "valid url" do
|
describe "valid url" do
|
||||||
it 'should allow for https urls' do
|
context "https urls" do
|
||||||
person = FactoryGirl.build(:person, :url => "https://example.com")
|
let(:person) { FactoryGirl.build(:person, url: "https://example.com") }
|
||||||
expect(person).to be_valid
|
|
||||||
|
it "should add trailing slash" do
|
||||||
|
expect(person.url).to eq("https://example.com/")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the receive url" do
|
||||||
|
expect(person.receive_url).to eq("https://example.com/receive/users/#{person.guid}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the atom url" do
|
||||||
|
expect(person.atom_url).to eq("https://example.com/public/#{person.username}.atom")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the profile url" do
|
||||||
|
expect(person.profile_url).to eq("https://example.com/u/#{person.username}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should always return the correct receive url' do
|
context "messed up urls" do
|
||||||
person = FactoryGirl.build(:person, :url => "https://example.com/a/bit/messed/up")
|
let(:person) { FactoryGirl.build(:person, url: "https://example.com/a/bit/messed/up") }
|
||||||
expect(person.receive_url).to eq("https://example.com/receive/users/#{person.guid}/")
|
|
||||||
|
it "should return the correct url" do
|
||||||
|
expect(person.url).to eq("https://example.com/")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the correct receive url" do
|
||||||
|
expect(person.receive_url).to eq("https://example.com/receive/users/#{person.guid}")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the correct atom url" do
|
||||||
|
expect(person.atom_url).to eq("https://example.com/public/#{person.username}.atom")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the correct profile url" do
|
||||||
|
expect(person.profile_url).to eq("https://example.com/u/#{person.username}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should allow ports in the url' do
|
it "should allow ports in the url" do
|
||||||
person = FactoryGirl.build(:person, :url => "https://example.com:3000/")
|
person = FactoryGirl.build(:person, url: "https://example.com:3000/")
|
||||||
expect(person.url).to eq("https://example.com:3000/")
|
expect(person.url).to eq("https://example.com:3000/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should remove https port in the url" do
|
||||||
|
person = FactoryGirl.build(:person, url: "https://example.com:443/")
|
||||||
|
expect(person.url).to eq("https://example.com/")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#diaspora_handle' do
|
describe '#diaspora_handle' do
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
require 'spec_helper'
|
require "spec_helper"
|
||||||
|
|
||||||
describe Workers::PublishToHub do
|
describe Workers::PublishToHub do
|
||||||
describe '.perform' do
|
describe ".perform" do
|
||||||
it 'calls pubsubhubbub' do
|
it "calls pubsubhubbub" do
|
||||||
url = "http://publiczone.com/"
|
url = "http://example.com/public/username.atom"
|
||||||
m = double()
|
m = double
|
||||||
|
|
||||||
expect(m).to receive(:publish).with(url+'.atom')
|
expect(m).to receive(:publish).with(url)
|
||||||
expect(Pubsubhubbub).to receive(:new).with(AppConfig.environment.pubsub_server).and_return(m)
|
expect(Pubsubhubbub).to receive(:new).with(AppConfig.environment.pubsub_server).and_return(m)
|
||||||
Workers::PublishToHub.new.perform(url)
|
Workers::PublishToHub.new.perform(url)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue