put receiving in a transaction, to prevent the crazy duplicate index errors and hopefully fix federation visibility.
This commit is contained in:
parent
fd68915461
commit
26151263c5
2 changed files with 44 additions and 41 deletions
|
|
@ -83,8 +83,8 @@ class Post < ActiveRecord::Base
|
||||||
#exists_locally?
|
#exists_locally?
|
||||||
#you know about it, and it is mutable
|
#you know about it, and it is mutable
|
||||||
#you know about it, and it is not mutable
|
#you know about it, and it is not mutable
|
||||||
|
self.class.transaction do
|
||||||
local_post = Post.where(:guid => self.guid).first
|
local_post = self.class.where(:guid => self.guid).first
|
||||||
if local_post && local_post.author_id == self.author_id
|
if local_post && local_post.author_id == self.author_id
|
||||||
known_post = user.find_visible_post_by_id(self.guid, :key => :guid)
|
known_post = user.find_visible_post_by_id(self.guid, :key => :guid)
|
||||||
if known_post
|
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}")
|
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
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def activity_streams?
|
def activity_streams?
|
||||||
false
|
false
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive(user, person)
|
def receive(user, person)
|
||||||
|
self.class.transaction do
|
||||||
object = self.class.where(:guid => self.guid).first || self
|
object = self.class.where(:guid => self.guid).first || self
|
||||||
|
|
||||||
unless object.parent.author == user.person || object.verify_parent_author_signature
|
unless object.parent.author == user.person || object.verify_parent_author_signature
|
||||||
|
|
@ -51,7 +52,7 @@ module Diaspora
|
||||||
|
|
||||||
#dispatch object DOWNSTREAM, received it via UPSTREAM
|
#dispatch object DOWNSTREAM, received it via UPSTREAM
|
||||||
unless user.owns?(object)
|
unless user.owns?(object)
|
||||||
object.save!
|
object.save
|
||||||
Postzord::Dispatch.new(user, object).post
|
Postzord::Dispatch.new(user, object).post
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -60,6 +61,7 @@ module Diaspora
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def after_receive(user, person)
|
def after_receive(user, person)
|
||||||
self
|
self
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue