Skip to content
Snippets Groups Projects
Commit 3b873453 authored by Daniel Grippi's avatar Daniel Grippi
Browse files

Merge pull request #2863 from Pistos/diasporainc-discard-unrecognized-relays

Gracefully handle unrecognized federated objects so failed Resque jobs don't pile up.
parents f3d790a4 44e6084a
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,14 @@ module Diaspora
doc = Nokogiri::XML(xml) { |cfg| cfg.noblanks }
return unless body = doc.xpath("/XML/post").children.first
class_name = body.name.gsub('-', '/')
class_name.camelize.constantize.from_xml body.to_s
begin
class_name.camelize.constantize.from_xml body.to_s
rescue NameError => e
# A pods is trying to federate an object we don't recognize.
# i.e. their codebase is different from ours. Quietly discard
# so that no Resque job failure is created
nil
end
end
end
end
......@@ -29,6 +29,7 @@ class Postzord::Receiver::Private < Postzord::Receiver
def parse_and_receive(xml)
@object ||= Diaspora::Parser.from_xml(xml)
return if @object.nil?
Rails.logger.info("event=receive status=start recipient=#{@user_person.diaspora_handle} payload_type=#{@object.class} sender=#{@sender.diaspora_handle}")
......
......@@ -7,7 +7,7 @@ class Postzord::Receiver::Public < Postzord::Receiver
attr_accessor :salmon, :author
def initialize(xml)
@salmon = Salmon::Slap.from_xml(xml)
@salmon = Salmon::Slap.from_xml(xml)
@author = Webfinger.new(@salmon.author_id).fetch
end
......@@ -47,7 +47,7 @@ class Postzord::Receiver::Public < Postzord::Receiver
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?
@object.save
@object.save if @object
end
# @return [Array<Integer>] User ids
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment