From 6273c2959ab044bbf00214b8c4727875323f91d7 Mon Sep 17 00:00:00 2001
From: Dennis Schubert <mail@dennis-schubert.de>
Date: Sat, 9 May 2015 21:38:51 +0200
Subject: [PATCH] Rescue from private objects sent to the public api

closes #5938
---
 Changelog.md                    | 1 +
 app/workers/base.rb             | 5 ++++-
 lib/postzord/receiver/public.rb | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 2ee9e9005b..409acf0b7a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -6,6 +6,7 @@
 * Dropped db/seeds.rb [#5896](https://github.com/diaspora/diaspora/pull/5896)
 * Drop broken install scripts [#5907](https://github.com/diaspora/diaspora/pull/5907)
 * Improve invoking mobile site in the testsuite [#5915](https://github.com/diaspora/diaspora/pull/5915)
+* Do not retry a couple of unrecoverable job failures [#5938](https://github.com/diaspora/diaspora/pull/5938)
 
 ## Bug fixes
 * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846)
diff --git a/app/workers/base.rb b/app/workers/base.rb
index 7fb53f548f..bb8315e502 100644
--- a/app/workers/base.rb
+++ b/app/workers/base.rb
@@ -14,7 +14,10 @@ module Workers
     rescue Diaspora::ContactRequiredUnlessRequest,
            Diaspora::RelayableObjectWithoutParent,
            # Friendica seems to provoke these
-           Diaspora::AuthorXMLAuthorMismatch => e
+           Diaspora::AuthorXMLAuthorMismatch,
+           # We received a private object to our public endpoint, again something
+           # Friendica seems to provoke
+           Diaspora::NonPublic => e
       Rails.logger.info("error on receive: #{e.class}")
     rescue ActiveRecord::RecordInvalid => e
       Rails.logger.info("failed to save received object: #{e.record.errors.full_messages}")
diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb
index d3f27be779..1851b4b98b 100644
--- a/lib/postzord/receiver/public.rb
+++ b/lib/postzord/receiver/public.rb
@@ -56,7 +56,7 @@ class Postzord::Receiver::Public < Postzord::Receiver
   # @return [Object]
   def save_object
     @object = Diaspora::Parser::from_xml(@salmon.parsed_data)
-    raise "Object is not public" if object_can_be_public_and_it_is_not?
+    raise Diaspora::NonPublic if object_can_be_public_and_it_is_not?
     raise Diaspora::RelayableObjectWithoutParent if object_must_have_parent_and_does_not?
     raise Diaspora::AuthorXMLAuthorMismatch if author_does_not_match_xml_author?
     @object.save! if @object && @object.respond_to?(:save!)
-- 
GitLab