use the parent author of the target as sender for relayable retractions
This commit is contained in:
parent
5e0b1dd28d
commit
9fda255add
2 changed files with 19 additions and 1 deletions
|
|
@ -29,7 +29,8 @@ class Retraction
|
||||||
|
|
||||||
def defer_dispatch(user, include_target_author=true)
|
def defer_dispatch(user, include_target_author=true)
|
||||||
subscribers = dispatch_subscribers(include_target_author)
|
subscribers = dispatch_subscribers(include_target_author)
|
||||||
Workers::DeferredRetraction.perform_async(user.id, data, subscribers.map(&:id), service_opts(user))
|
sender = dispatch_sender(user)
|
||||||
|
Workers::DeferredRetraction.perform_async(sender.id, data, subscribers.map(&:id), service_opts(user))
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
|
|
@ -52,6 +53,11 @@ class Retraction
|
||||||
subscribers
|
subscribers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @deprecated This is only needed for pre 0.6 pods
|
||||||
|
def dispatch_sender(user)
|
||||||
|
target.try(:sender_for_dispatch) || user
|
||||||
|
end
|
||||||
|
|
||||||
def service_opts(user)
|
def service_opts(user)
|
||||||
return {} unless target.is_a?(StatusMessage)
|
return {} unless target.is_a?(StatusMessage)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,18 @@ describe Retraction do
|
||||||
Retraction.for(comment, local_luke).defer_dispatch(local_luke)
|
Retraction.for(comment, local_luke).defer_dispatch(local_luke)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "uses the author of the target parent as sender for a comment-retraction if the parent is local" do
|
||||||
|
post = local_luke.post(:status_message, text: "hello", public: true)
|
||||||
|
comment = local_leia.comment!(post, "destroy!")
|
||||||
|
federation_retraction = Diaspora::Federation::Entities.relayable_retraction(comment, local_leia)
|
||||||
|
|
||||||
|
expect(Workers::DeferredRetraction).to receive(:perform_async).with(
|
||||||
|
local_luke.id, federation_retraction.to_h, [remote_raphael.id], {}
|
||||||
|
)
|
||||||
|
|
||||||
|
Retraction.for(comment, local_leia).defer_dispatch(local_leia)
|
||||||
|
end
|
||||||
|
|
||||||
context "relayable" do
|
context "relayable" do
|
||||||
let(:post) { local_luke.post(:status_message, text: "hello", public: true) }
|
let(:post) { local_luke.post(:status_message, text: "hello", public: true) }
|
||||||
let(:comment) { FactoryGirl.create(:comment, post: post, author: remote_raphael) }
|
let(:comment) { FactoryGirl.create(:comment, post: post, author: remote_raphael) }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue