From 915dee3c4b9ec0b3f8413cf00b8251116143e3fd Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Fri, 8 May 2015 00:49:29 +0200 Subject: [PATCH] Mute some ActiveRecord::RecordNotUnique exceptions --- app/workers/base.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/workers/base.rb b/app/workers/base.rb index c43f60929..7fb53f548 100644 --- a/app/workers/base.rb +++ b/app/workers/base.rb @@ -13,12 +13,22 @@ module Workers yield rescue Diaspora::ContactRequiredUnlessRequest, Diaspora::RelayableObjectWithoutParent, - # Friendica seems to provoke these + # Friendica seems to provoke these Diaspora::AuthorXMLAuthorMismatch => 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