put receiving in a transaction, to prevent the crazy duplicate index errors and hopefully fix federation visibility.

This commit is contained in:
Maxwell Salzberg 2011-09-03 16:04:53 -07:00
parent fd68915461
commit 26151263c5
2 changed files with 44 additions and 41 deletions

View file

@ -83,8 +83,8 @@ class Post < ActiveRecord::Base
#exists_locally?
#you know about it, and it is mutable
#you know about it, and it is not mutable
local_post = Post.where(:guid => self.guid).first
self.class.transaction do
local_post = self.class.where(:guid => self.guid).first
if local_post && local_post.author_id == self.author_id
known_post = user.find_visible_post_by_id(self.guid, :key => :guid)
if known_post
@ -112,6 +112,7 @@ class Post < ActiveRecord::Base
Rails.logger.info("event=receive payload_type=#{self.class} update=true status=abort sender=#{self.diaspora_handle} reason='update not from post owner' existing_post=#{self.id}")
end
end
end
def activity_streams?
false

View file

@ -36,6 +36,7 @@ module Diaspora
end
def receive(user, person)
self.class.transaction do
object = self.class.where(:guid => self.guid).first || self
unless object.parent.author == user.person || object.verify_parent_author_signature
@ -51,7 +52,7 @@ module Diaspora
#dispatch object DOWNSTREAM, received it via UPSTREAM
unless user.owns?(object)
object.save!
object.save
Postzord::Dispatch.new(user, object).post
end
@ -60,6 +61,7 @@ module Diaspora
object
end
end
end
def after_receive(user, person)
self