Merge branch 'stable' into develop

This commit is contained in:
Dennis Schubert 2015-11-22 02:52:37 +01:00
commit 5081d69847
5 changed files with 43 additions and 0 deletions

View file

@ -96,6 +96,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure.
* Fix notifications for interactions by non-contacts [#6498](https://github.com/diaspora/diaspora/pull/6498)
* Fix issue where the publisher was broken on profile pages [#6503](https://github.com/diaspora/diaspora/pull/6503)
* Prevent participations being created for invalid interactions [#6552](https://github.com/diaspora/diaspora/pull/6552)
* Improve federation for reshare related interactions [#6481](https://github.com/diaspora/diaspora/pull/6481)
## Features

View file

@ -59,6 +59,7 @@ class Reshare < Post
def receive(recipient, sender)
local_reshare = Reshare.where(:guid => self.guid).first
if local_reshare && local_reshare.root.author_id == recipient.person.id
recipient.participate! self
return unless recipient.has_contact_for?(sender)
end
super(recipient, sender)

View file

@ -12,11 +12,20 @@ module Federated
relayable = build(options)
if relayable.save!
logger.info "user:#{@user.id} dispatching #{relayable.class}:#{relayable.guid}"
add_root_author(relayable)
Postzord::Dispatcher.defer_build_and_post(@user, relayable, @dispatcher_opts)
relayable
end
end
def add_root_author(relayable)
return unless relayable.parent.respond_to?(:root) && relayable.parent.root
# Comment post is a reshare, include original author in subscribers
root_post = relayable.parent.root
@dispatcher_opts[:additional_subscribers] ||= []
@dispatcher_opts[:additional_subscribers] << root_post.author
end
def build(options={})
options.merge!(relayable_options)
relayable = self.class.federated_class.new(options.merge(:author_id => @user.person.id))

View file

@ -0,0 +1,25 @@
require "spec_helper"
describe "adds root author on reshare" do
before do
@generator = Federated::Generator.new(double("user", id: 1), double)
@root_author = double("root_author")
root = double("root", author: @root_author)
parent = double("parent", root: root)
@relayable = double("relayable", parent: parent, class: "foo", guid: "123")
end
it "adds root to additional subscribers" do
@generator.add_root_author(@relayable)
additional_subscribers = @generator.instance_variable_get(:@dispatcher_opts)[:additional_subscribers]
expect(additional_subscribers).to include(@root_author)
end
it "calls add_root_author" do
allow(Postzord::Dispatcher).to receive(:defer_build_and_post).and_return(true)
allow(@generator).to receive(:build).and_return(@relayable)
allow(@relayable).to receive(:save!).and_return(true)
expect(@generator).to receive(:add_root_author)
@generator.create!
end
end

View file

@ -51,6 +51,7 @@ describe Reshare, type: :model do
receive_reshare
expect(@root.resharers).to include(@reshare.author)
end
it "does not error if the root author has a contact for the resharer" do
bob.share_with @reshare.author, bob.aspects.first
expect {
@ -59,6 +60,12 @@ describe Reshare, type: :model do
end
}.not_to raise_error
end
it "participates root author in the reshare" do
receive_reshare
participations = Participation.where(target_id: @reshare.id, author_id: @root.author_id)
expect(participations.count).to eq(1)
end
end
describe "#nsfw" do