send retractions for public relayables privately if the parent is remote

This commit is contained in:
Benjamin Neff 2016-06-18 19:36:34 +02:00
parent b3a9bf3925
commit 9dfa8e1442
2 changed files with 14 additions and 2 deletions

View file

@ -38,7 +38,8 @@ class Retraction
end end
def public? 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 end
private private

View file

@ -108,10 +108,21 @@ describe Retraction do
end end
describe "#public?" do 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 expect(Retraction.for(post, alice).public?).to be_truthy
end 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 it "returns false for a private target" do
private_post = alice.post(:status_message, text: "destroy!", to: alice.aspects.first.id) private_post = alice.post(:status_message, text: "destroy!", to: alice.aspects.first.id)
expect(Retraction.for(private_post, alice).public?).to be_falsey expect(Retraction.for(private_post, alice).public?).to be_falsey