diff --git a/config/initializers/diaspora_federation.rb b/config/initializers/diaspora_federation.rb index 4d63aebd2..27d458917 100644 --- a/config/initializers/diaspora_federation.rb +++ b/config/initializers/diaspora_federation.rb @@ -106,7 +106,11 @@ DiasporaFederation.configure do |config| end end - on :save_entity_after_receive do + on :receive_entity do + # TODO + end + + on :update_pod do # TODO end end diff --git a/spec/integration/federation/federation_helper.rb b/spec/integration/federation/federation_helper.rb index dd3609b71..f9340517b 100644 --- a/spec/integration/federation/federation_helper.rb +++ b/spec/integration/federation/federation_helper.rb @@ -20,11 +20,10 @@ def create_remote_user(pod) end def create_relayable_entity(entity_name, target, diaspora_id, parent_author_key) - target_entity_type = FactoryGirl.factory_by_name(entity_name).build_class.get_target_entity_type(@entity.to_h) expect(DiasporaFederation.callbacks).to receive(:trigger) .with( :fetch_author_private_key_by_entity_guid, - target_entity_type, + FactoryGirl.build(entity_name).parent_type, target.guid ) .and_return(parent_author_key) @@ -33,19 +32,18 @@ def create_relayable_entity(entity_name, target, diaspora_id, parent_author_key) entity_name, conversation_guid: target.guid, parent_guid: target.guid, - diaspora_id: diaspora_id, + author: diaspora_id, poll_answer_guid: target.respond_to?(:poll_answers) ? target.poll_answers.first.guid : nil ) end def generate_xml(entity, remote_user, recipient=nil) if recipient - DiasporaFederation::Salmon::EncryptedSlap.generate_xml( + DiasporaFederation::Salmon::EncryptedSlap.prepare( remote_user.diaspora_handle, OpenSSL::PKey::RSA.new(remote_user.encryption_key), - entity, - OpenSSL::PKey::RSA.new(recipient.encryption_key) - ) + entity + ).generate_xml(OpenSSL::PKey::RSA.new(recipient.encryption_key)) else DiasporaFederation::Salmon::Slap.generate_xml( remote_user.diaspora_handle, diff --git a/spec/integration/federation/receive_federation_messages_spec.rb b/spec/integration/federation/receive_federation_messages_spec.rb index 2c24a5aa2..3c5bc1605 100644 --- a/spec/integration/federation/receive_federation_messages_spec.rb +++ b/spec/integration/federation/receive_federation_messages_spec.rb @@ -36,7 +36,7 @@ describe "Receive federation messages feature" do it "reshare of public post passes" do post = FactoryGirl.create(:status_message, author: alice.person, public: true) reshare = FactoryGirl.build( - :reshare_entity, root_diaspora_id: alice.diaspora_handle, root_guid: post.guid, diaspora_id: sender_id) + :reshare_entity, root_author: alice.diaspora_handle, root_guid: post.guid, author: sender_id) post_message(generate_xml(reshare, sender)) expect(Reshare.exists?(root_guid: post.guid, diaspora_handle: sender_id)).to be_truthy @@ -45,7 +45,7 @@ describe "Receive federation messages feature" do it "reshare of private post fails" do post = FactoryGirl.create(:status_message, author: alice.person, public: false) reshare = FactoryGirl.build( - :reshare_entity, root_diaspora_id: alice.diaspora_handle, root_guid: post.guid, diaspora_id: sender_id) + :reshare_entity, root_author: alice.diaspora_handle, root_guid: post.guid, author: sender_id) expect { post_message(generate_xml(reshare, sender)) }.to raise_error ActiveRecord::RecordInvalid, "Validation failed: Only posts which are public may be reshared." @@ -72,7 +72,7 @@ describe "Receive federation messages feature" do let(:recipient) { alice } it "treats sharing request recive correctly" do - entity = FactoryGirl.build(:request_entity, recipient_id: alice.diaspora_handle) + entity = FactoryGirl.build(:request_entity, recipient: alice.diaspora_handle) expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times @@ -94,7 +94,7 @@ describe "Receive federation messages feature" do end it "doesn't save the private status message if there is no sharing" do - entity = FactoryGirl.build(:status_message_entity, diaspora_id: sender_id, public: false) + entity = FactoryGirl.build(:status_message_entity, author: sender_id, public: false) post_message(generate_xml(entity, sender, alice), alice) expect(StatusMessage.exists?(guid: entity.guid)).to be_falsey @@ -111,7 +111,7 @@ describe "Receive federation messages feature" do it_behaves_like "messages which can't be send without sharing" it "treats profile receive correctly" do - entity = FactoryGirl.build(:profile_entity, diaspora_id: sender_id) + entity = FactoryGirl.build(:profile_entity, author: sender_id) post_message(generate_xml(entity, sender, alice), alice) expect(Profile.exists?(diaspora_handle: entity.diaspora_id)).to be_truthy @@ -120,8 +120,8 @@ describe "Receive federation messages feature" do it "receives conversation correctly" do entity = FactoryGirl.build( :conversation_entity, - diaspora_id: sender_id, - participant_ids: "#{sender_id};#{alice.diaspora_handle}" + author: sender_id, + participants: "#{sender_id};#{alice.diaspora_handle}" ) post_message(generate_xml(entity, sender, alice), alice) diff --git a/spec/integration/federation/shared_receive_retraction.rb b/spec/integration/federation/shared_receive_retraction.rb index c9182e539..e4e2612a7 100644 --- a/spec/integration/federation/shared_receive_retraction.rb +++ b/spec/integration/federation/shared_receive_retraction.rb @@ -9,7 +9,7 @@ def retraction_entity(entity_name, target_object, sender) FactoryGirl.build( entity_name, - diaspora_id: sender.diaspora_handle, + author: sender.diaspora_handle, target_guid: target_object.guid, target_type: target_object.class.to_s ) diff --git a/spec/integration/federation/shared_receive_stream_items.rb b/spec/integration/federation/shared_receive_stream_items.rb index 93e876481..6d7456836 100644 --- a/spec/integration/federation/shared_receive_stream_items.rb +++ b/spec/integration/federation/shared_receive_stream_items.rb @@ -4,7 +4,7 @@ shared_examples_for "messages which are indifferent about sharing fact" do let(:public) { recipient.nil? } it "treats status message receive correctly" do - entity = FactoryGirl.build(:status_message_entity, diaspora_id: sender_id, public: public) + entity = FactoryGirl.build(:status_message_entity, author: sender_id, public: public) post_message(generate_xml(entity, sender, recipient), recipient) @@ -13,7 +13,7 @@ shared_examples_for "messages which are indifferent about sharing fact" do it "doesn't accept status message with wrong signature" do allow(sender).to receive(:encryption_key).and_return(OpenSSL::PKey::RSA.new(1024)) - entity = FactoryGirl.build(:status_message_entity, diaspora_id: sender_id, public: public) + entity = FactoryGirl.build(:status_message_entity, author: sender_id, public: public) post_message(generate_xml(entity, sender, recipient), recipient)