From 9dfa8e14428bdf324bdeb58cced1ab65d1ed24f8 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sat, 18 Jun 2016 19:36:34 +0200 Subject: [PATCH] send retractions for public relayables privately if the parent is remote --- lib/diaspora/federated/retraction.rb | 3 ++- spec/lib/diaspora/federated/retraction_spec.rb | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/diaspora/federated/retraction.rb b/lib/diaspora/federated/retraction.rb index 55fcc8668..7c7ce2a26 100644 --- a/lib/diaspora/federated/retraction.rb +++ b/lib/diaspora/federated/retraction.rb @@ -38,7 +38,8 @@ class Retraction end def public? - data[:target][:public] + # TODO: backward compatibility for pre 0.6 pods, they don't relay public retractions + data[:target][:public] && (!data[:target][:parent] || data[:target][:parent][:local]) end private diff --git a/spec/lib/diaspora/federated/retraction_spec.rb b/spec/lib/diaspora/federated/retraction_spec.rb index b303cdd4d..ecc7e3cd7 100644 --- a/spec/lib/diaspora/federated/retraction_spec.rb +++ b/spec/lib/diaspora/federated/retraction_spec.rb @@ -108,10 +108,21 @@ describe Retraction do end describe "#public?" do - it "returns true for a public target" do + it "returns true for a public post" do expect(Retraction.for(post, alice).public?).to be_truthy end + it "returns true for a public comment if parent post is local" do + comment = bob.comment!(post, "destroy!") + expect(Retraction.for(comment, bob).public?).to be_truthy + end + + it "returns false for a public comment if parent post is not local" do + remote_post = FactoryGirl.create(:status_message, author: remote_raphael) + comment = alice.comment!(remote_post, "destroy!") + expect(Retraction.for(comment, alice).public?).to be_falsey + end + it "returns false for a private target" do private_post = alice.post(:status_message, text: "destroy!", to: alice.aspects.first.id) expect(Retraction.for(private_post, alice).public?).to be_falsey