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

Merge pull request #6887 from SuperTux88/fix-relayable-retraction-sender

Fix relayable retraction sender
parents 5bed75b6 9fda255a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
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