Merge pull request #6887 from SuperTux88/fix-relayable-retraction-sender
Fix relayable retraction sender
This commit is contained in:
commit
9a033c7f68
3 changed files with 20 additions and 2 deletions
|
|
@ -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) }
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ describe CommentService do
|
|||
post = alice.post(:status_message, text: "hello", public: true)
|
||||
comments = [alice, bob, eve].map {|user| CommentService.new(user).create(post.id, "hi") }
|
||||
|
||||
expect(CommentService.new.find_for_post(post.id)).to eq(comments)
|
||||
expect(CommentService.new.find_for_post(post.id)).to match_array(comments)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue