Commit 9fda255a authored by Benjamin Neff's avatar Benjamin Neff

use the parent author of the target as sender for relayable retractions

parent 5e0b1dd2
......@@ -29,7 +29,8 @@ class Retraction
def defer_dispatch(user, include_target_author=true)
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
def perform
......@@ -52,6 +53,11 @@ class Retraction
subscribers
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)
return {} unless target.is_a?(StatusMessage)
......
......@@ -99,6 +99,18 @@ describe Retraction do
Retraction.for(comment, local_luke).defer_dispatch(local_luke)
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
let(:post) { local_luke.post(:status_message, text: "hello", public: true) }
let(:comment) { FactoryGirl.create(:comment, post: post, author: remote_raphael) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment