Rescue from private objects sent to the public api

closes #5938
This commit is contained in:
Dennis Schubert 2015-05-09 21:38:51 +02:00 committed by Jonne Haß
parent 915dee3c4b
commit 6273c2959a
3 changed files with 6 additions and 2 deletions

View file

@ -6,6 +6,7 @@
* Dropped db/seeds.rb [#5896](https://github.com/diaspora/diaspora/pull/5896) * Dropped db/seeds.rb [#5896](https://github.com/diaspora/diaspora/pull/5896)
* Drop broken install scripts [#5907](https://github.com/diaspora/diaspora/pull/5907) * 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) * 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 ## Bug fixes
* Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846) * Disable auto follow back on aspect deletion [#5846](https://github.com/diaspora/diaspora/pull/5846)

View file

@ -14,7 +14,10 @@ module Workers
rescue Diaspora::ContactRequiredUnlessRequest, rescue Diaspora::ContactRequiredUnlessRequest,
Diaspora::RelayableObjectWithoutParent, Diaspora::RelayableObjectWithoutParent,
# Friendica seems to provoke these # 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}") Rails.logger.info("error on receive: #{e.class}")
rescue ActiveRecord::RecordInvalid => e rescue ActiveRecord::RecordInvalid => e
Rails.logger.info("failed to save received object: #{e.record.errors.full_messages}") Rails.logger.info("failed to save received object: #{e.record.errors.full_messages}")

View file

@ -56,7 +56,7 @@ class Postzord::Receiver::Public < Postzord::Receiver
# @return [Object] # @return [Object]
def save_object def save_object
@object = Diaspora::Parser::from_xml(@salmon.parsed_data) @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::RelayableObjectWithoutParent if object_must_have_parent_and_does_not?
raise Diaspora::AuthorXMLAuthorMismatch if author_does_not_match_xml_author? raise Diaspora::AuthorXMLAuthorMismatch if author_does_not_match_xml_author?
@object.save! if @object && @object.respond_to?(:save!) @object.save! if @object && @object.respond_to?(:save!)