Skip to content

Instantly share code, notes, and snippets.

@Pistos
Created December 27, 2011 16:24
Show Gist options
  • Save Pistos/1524247 to your computer and use it in GitHub Desktop.
Save Pistos/1524247 to your computer and use it in GitHub Desktop.
diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb
index 277de7b..df8969c 100644
--- a/lib/postzord/receiver/public.rb
+++ b/lib/postzord/receiver/public.rb
@@ -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
@@ -45,7 +45,12 @@ 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
+ begin
+ @object.save
+ rescue ActiveRecord::RecordNotUnique
+ # We already have this object; silently discard
+ nil
+ end
end
# @return [Array<Integer>] User ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment