From 499ff6e0f463d7fdd53119d76b1aa444f0ddd7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= <me@jhass.eu> Date: Sat, 20 Sep 2014 15:03:53 +0200 Subject: [PATCH] Fix receiving a relayable retraction through the public route --- lib/diaspora/federated/relayable_retraction.rb | 4 ++++ lib/postzord/receiver/public.rb | 10 +++++----- .../diaspora/federated/relayable_retraction_spec.rb | 7 +++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/diaspora/federated/relayable_retraction.rb b/lib/diaspora/federated/relayable_retraction.rb index ab7be6528b..3d48f67632 100644 --- a/lib/diaspora/federated/relayable_retraction.rb +++ b/lib/diaspora/federated/relayable_retraction.rb @@ -60,4 +60,8 @@ class RelayableRetraction < SignedRetraction def parent_author_signature_valid? verify_signature(self.parent_author_signature, self.parent.author) end + + def parent_diaspora_handle + target.author.diaspora_handle + end end diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb index 0243b72f52..d3f27be779 100644 --- a/lib/postzord/receiver/public.rb +++ b/lib/postzord/receiver/public.rb @@ -26,15 +26,15 @@ class Postzord::Receiver::Public < Postzord::Receiver return false unless save_object FEDERATION_LOGGER.info("received a #{@object.inspect}") - if @object.respond_to?(:relayable?) - receive_relayable - elsif @object.is_a?(AccountDeletion) - #nothing - elsif @object.is_a?(SignedRetraction) # feels like a hack + if @object.is_a?(SignedRetraction) # feels like a hack self.recipient_user_ids.each do |user_id| user = User.where(id: user_id).first @object.perform user if user end + elsif @object.respond_to?(:relayable?) + receive_relayable + elsif @object.is_a?(AccountDeletion) + #nothing else Workers::ReceiveLocalBatch.perform_async(@object.class.to_s, @object.id, self.recipient_user_ids) true diff --git a/spec/lib/diaspora/federated/relayable_retraction_spec.rb b/spec/lib/diaspora/federated/relayable_retraction_spec.rb index baf88a6eb5..6e8635a248 100644 --- a/spec/lib/diaspora/federated/relayable_retraction_spec.rb +++ b/spec/lib/diaspora/federated/relayable_retraction_spec.rb @@ -98,6 +98,13 @@ describe RelayableRetraction do expect(Postzord::Dispatcher).not_to receive(:build) @retraction.receive(@recipient, @remote_raphael) end + + it 'performs through postzord' do + xml = Salmon::Slap.create_by_user_and_activity(@local_luke, @retraction.to_diaspora_xml).xml_for(nil) + expect { + Postzord::Receiver::Public.new(xml).perform! + }.to change(Comment, :count).by(-1) + end end end -- GitLab