diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 1ec55eef03253cac40da3eea7d126e13e675cc3b..e6d925c57e0128c78d66fa02d9ab9ad1629fe833 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -63,6 +63,12 @@ class Reshare < Post @absolute_root end + def receive(recipient_user_ids) + super(recipient_user_ids) + + root.author.owner.participate!(self) if root.author.local? + end + def subscribers super + [root.author] end diff --git a/spec/integration/federation/receive_federation_messages_spec.rb b/spec/integration/federation/receive_federation_messages_spec.rb index 7144ffdfab78e8025a2d932fd91889e62ef9b014..b0139b8d8dfe5d8a2c263187fcb18757334876c5 100644 --- a/spec/integration/federation/receive_federation_messages_spec.rb +++ b/spec/integration/federation/receive_federation_messages_spec.rb @@ -34,6 +34,11 @@ describe "Receive federation messages feature" do post = FactoryGirl.create(:status_message, author: alice.person, public: true) reshare = FactoryGirl.build( :reshare_entity, root_author: alice.diaspora_handle, root_guid: post.guid, author: sender_id) + + expect(Participation::Generator).to receive(:new).with( + alice, instance_of(Reshare) + ).and_return(double(create!: true)) + post_message(generate_xml(reshare, sender)) expect(Reshare.exists?(root_guid: post.guid)).to be_truthy diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 5ad2d96434f86a10ac13be0c11d95a425524c858..3ae0dfc883600034634d884b117481781567ec80 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -33,6 +33,15 @@ describe Reshare, type: :model do end end + describe "#receive" do + let(:reshare) { create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true)) } + + it "participates root author in the reshare" do + reshare.receive([]) + expect(Participation.count(target_id: reshare.id, author_id: bob.person.id)).to eq(1) + end + end + describe "#nsfw" do let(:sfw) { build(:status_message, author: alice.person, public: true) } let(:nsfw) { build(:status_message, author: alice.person, public: true, text: "This is #nsfw") }