diff options
author | Raphael Sofaer <raphael@joindiaspora.com> | 2011-07-23 01:19:58 +0400 |
---|---|---|
committer | Raphael Sofaer <raphael@joindiaspora.com> | 2011-07-23 01:19:58 +0400 |
commit | 4b1d5b772d4d812c231dbd713c5dcf9197b28002 (patch) | |
tree | 915948a39bcd5a8b01d3b2d0463281840c4a6107 /app | |
parent | ad5dba052ca7c2d67e9e7c64ff8d46f84b2ab791 (diff) |
Failing spec for the second retraction for a reshared post, reshares need to refer to guids
Diffstat (limited to 'app')
-rw-r--r-- | app/models/reshare.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 72e3ccbca..9ba63bcd9 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -43,8 +43,7 @@ class Reshare < Post local_post = Post.where(:guid => @root_guid).select('id').first unless local_post && self.root_id = local_post.id - response = Faraday.get(root_author.url + "/p/#{@root_guid}.xml") - received_post = Diaspora::Parser.from_xml(response.body) + received_post = self.class.fetch_post(root_author, @root_guid) unless post = received_post.class.where(:guid => received_post.guid).first post = received_post @@ -61,6 +60,15 @@ class Reshare < Post end end + # Fetch a remote public post, used for receiving reshares of unknown posts + # @param [Person] author the remote post's author + # @param [String] guid the remote post's guid + # @return [Post] an unsaved remote post + def self.fetch_post author, guid + response = Faraday.get(root_author.url + "/p/#{@root_guid}.xml") + Diaspora::Parser.from_xml(response.body) + end + def root_must_be_public if self.root && !self.root.public errors[:base] << "you must reshare public posts" |