diff options
author | Raphael Sofaer <raphael@joindiaspora.com> | 2011-07-21 00:10:29 +0400 |
---|---|---|
committer | Raphael Sofaer <raphael@joindiaspora.com> | 2011-07-22 05:23:33 +0400 |
commit | 7382dfb7be498d3c9d2b37311fd88ac98158074d (patch) | |
tree | ed8be141398dcfe4d06323b4805f614f52e85fe6 /app | |
parent | e19fb6d0f885afaaaa48708da2f29f60ecfc2bed (diff) |
Multi-server spec now successfully passes along a reshare
Diffstat (limited to 'app')
-rw-r--r-- | app/models/person.rb | 1 | ||||
-rw-r--r-- | app/models/reshare.rb | 14 |
2 files changed, 8 insertions, 7 deletions
diff --git a/app/models/person.rb b/app/models/person.rb index 68d18a011..756a00ef7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -235,7 +235,6 @@ class Person < ActiveRecord::Base protected def clean_url - self.url ||= "http://localhost:3000/" if self.class == User if self.url self.url = 'http://' + self.url unless self.url.match(/https?:\/\//) self.url = self.url + '/' if self.url[-1, 1] != '/' diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 8a9bed4a3..80bbeb47f 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -1,4 +1,4 @@ -class Reshare < Post +class Reshare < Post belongs_to :root, :class_name => 'Post' validate :root_must_be_public @@ -7,12 +7,12 @@ class Reshare < Post xml_attr :root_diaspora_id xml_attr :root_guid - before_validation do + before_validation do self.public = true end def root_guid - self.root.guid + self.root.guid end def root_diaspora_id @@ -21,9 +21,9 @@ class Reshare < Post def receive(user, person) local_reshare = Reshare.where(:guid => self.guid).first - if local_reshare.root.author_id == user.person.id + if local_reshare && local_reshare.root.author_id == user.person.id local_reshare.root.reshares << local_reshare - + if user.contact_for(person) local_reshare.receive(user, person) end @@ -42,7 +42,9 @@ class Reshare < Post local_post = Post.where(:guid => @root_guid).select('id').first unless local_post && self.root_id = local_post.id - received_post = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}.xml").body) + response = Faraday.get(root_author.url + "/p/#{@root_guid}.xml") + received_post = Diaspora::Parser.from_xml(response.body) + unless post = received_post.class.where(:guid => received_post.guid).first post = received_post |