diff --git a/Changelog.md b/Changelog.md index c9ff3dedd..f3b7b3cc1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -21,6 +21,7 @@ Ruby 2.0 is no longer officially supported. * 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 c43f60929..bb8315e50 100644 --- a/app/workers/base.rb +++ b/app/workers/base.rb @@ -13,12 +13,25 @@ module Workers yield rescue Diaspora::ContactRequiredUnlessRequest, Diaspora::RelayableObjectWithoutParent, - # Friendica seems to provoke these - Diaspora::AuthorXMLAuthorMismatch => e + # Friendica seems to provoke these + 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}") raise e unless e.message.match(/already been taken/) + rescue ActiveRecord::RecordNotUnique => e + Rails.logger.info("failed to save received object: #{e.record.errors.full_messages}") + raise e unless %w( + index_comments_on_guid + index_likes_on_guid + index_posts_on_guid + "duplicate key in table 'comments'" + "duplicate key in table 'likes'" + "duplicate key in table 'posts'" + ).any? {|index| e.message.include? index } end end end diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb index d3f27be77..1851b4b98 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!)