Skip to content
Extraits de code Groupes Projets
Valider 5e16b9c7 rédigé par Benjamin Neff's avatar Benjamin Neff
Parcourir les fichiers

add author to subscribers of public shareables to ensure local delivery

parent a81bdac3
Branches
Étiquettes
Aucune requête de fusion associée trouvée
......@@ -46,7 +46,7 @@ module Diaspora
def subscribers
user = author.owner
if public?
user.contact_people
[*user.contact_people, author]
else
user.people_in_aspects(user.aspects_with_shareable(self.class, id))
end
......
......@@ -220,23 +220,29 @@ describe Post, :type => :model do
context "public" do
let(:post) { user.post(:status_message, text: "hello", public: true) }
it "returns the author to ensure local delivery" do
lonely_user = FactoryGirl.create(:user)
lonely_post = lonely_user.post(:status_message, text: "anyone?", public: true)
expect(lonely_post.subscribers).to match_array([lonely_user.person])
end
it "returns all a users contacts if the post is public" do
second_aspect = user.aspects.create(name: "winners")
user.share_with(bob.person, second_aspect)
expect(post.subscribers).to eq([alice.person, bob.person])
expect(post.subscribers).to match_array([alice.person, bob.person, user.person])
end
it "adds resharers to subscribers" do
FactoryGirl.create(:reshare, root: post, author: eve.person)
expect(post.subscribers).to eq([alice.person, eve.person])
expect(post.subscribers).to match_array([alice.person, eve.person, user.person])
end
it "adds participants to subscribers" do
eve.participate!(post)
expect(post.subscribers).to eq([alice.person, eve.person])
expect(post.subscribers).to match_array([alice.person, eve.person, user.person])
end
end
end
......
......@@ -133,7 +133,7 @@ describe Reshare, type: :model do
post = eve.post(:status_message, text: "hello", public: true)
reshare = FactoryGirl.create(:reshare, root: post, author: user.person)
expect(reshare.subscribers).to eq([alice.person, eve.person])
expect(reshare.subscribers).to match_array([alice.person, eve.person, user.person])
end
end
end
......@@ -42,7 +42,8 @@ shared_examples "a dispatcher" do
context "deliver to local user" do
it "queues receive local job for all local receivers" do
expect(Workers::ReceiveLocal).to receive(:perform_async).with("StatusMessage", post.id, [bob.id])
local_subscriber_ids = post.subscribers.select(&:local?).map(&:owner_id)
expect(Workers::ReceiveLocal).to receive(:perform_async).with("StatusMessage", post.id, local_subscriber_ids)
Diaspora::Federation::Dispatcher.build(alice, post).dispatch
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter