use the parent author as salmon sender, if the parent author is local
This commit is contained in:
parent
84ec00fa4d
commit
7241b1c054
3 changed files with 27 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ module Diaspora
|
|||
end
|
||||
|
||||
def self.build(sender, object, opts={})
|
||||
sender = object.try(:sender_for_dispatch) || sender
|
||||
if object.try(:public?)
|
||||
Public.new(sender, object, opts)
|
||||
else
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ module Diaspora
|
|||
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
|
||||
def parent
|
||||
raise NotImplementedError.new('you must override parent in order to enable relayable on this model')
|
||||
|
|
|
|||
|
|
@ -32,6 +32,27 @@ describe Diaspora::Federation::Dispatcher do
|
|||
|
||||
expect(dispatcher).to be_instance_of(Diaspora::Federation::Dispatcher::Private)
|
||||
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
|
||||
|
||||
describe ".defer_dispatch" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue