Created
December 27, 2011 16:24
-
-
Save Pistos/1524247 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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