Skip to content
Extraits de code Groupes Projets
Valider 5bed75b6 rédigé par Dennis Schubert's avatar Dennis Schubert
Parcourir les fichiers

Merge pull request #6886 from SuperTux88/fix-relayable-sender

use the parent author as salmon sender, if the parent author is local
parents 84ec00fa 7241b1c0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -10,6 +10,7 @@ module Diaspora ...@@ -10,6 +10,7 @@ module Diaspora
end end
def self.build(sender, object, opts={}) def self.build(sender, object, opts={})
sender = object.try(:sender_for_dispatch) || sender
if object.try(:public?) if object.try(:public?)
Public.new(sender, object, opts) Public.new(sender, object, opts)
else else
......
...@@ -40,6 +40,11 @@ module Diaspora ...@@ -40,6 +40,11 @@ module Diaspora
end end
end end
# @deprecated This is only needed for pre 0.6 pods
def sender_for_dispatch
parent.author.owner if parent.author.local?
end
# @abstract # @abstract
def parent def parent
raise NotImplementedError.new('you must override parent in order to enable relayable on this model') raise NotImplementedError.new('you must override parent in order to enable relayable on this model')
......
...@@ -32,6 +32,27 @@ describe Diaspora::Federation::Dispatcher do ...@@ -32,6 +32,27 @@ describe Diaspora::Federation::Dispatcher do
expect(dispatcher).to be_instance_of(Diaspora::Federation::Dispatcher::Private) expect(dispatcher).to be_instance_of(Diaspora::Federation::Dispatcher::Private)
end end
it "uses the parent author as sender for a comment if the parent is local" do
comment = FactoryGirl.create(:comment, author: bob.person, post: post)
expect(Diaspora::Federation::Dispatcher::Public).to receive(:new).with(alice, comment, {}).and_call_original
dispatcher = described_class.build(bob, comment)
expect(dispatcher).to be_instance_of(Diaspora::Federation::Dispatcher::Public)
end
it "uses the original sender for a comment if the parent is not local" do
remote_post = FactoryGirl.create(:status_message, author: remote_raphael, text: "hello", public: true)
comment = FactoryGirl.create(:comment, author: bob.person, post: remote_post)
expect(Diaspora::Federation::Dispatcher::Public).to receive(:new).with(bob, comment, {}).and_call_original
dispatcher = described_class.build(bob, comment)
expect(dispatcher).to be_instance_of(Diaspora::Federation::Dispatcher::Public)
end
end end
describe ".defer_dispatch" do describe ".defer_dispatch" do
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter