dont do the comments in a transaction, we build other jobs
This commit is contained in:
parent
6c414d8562
commit
1343188ccb
1 changed files with 19 additions and 22 deletions
|
|
@ -46,33 +46,30 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive(user, person=nil)
|
def receive(user, person=nil)
|
||||||
|
comment_or_like = self.class.where(:guid => self.guid).first || self
|
||||||
|
|
||||||
self.class.transaction do
|
#check to make sure the signature of the comment or like comes from the person claiming to authoring said comment or like
|
||||||
comment_or_like = self.class.where(:guid => self.guid).first || self
|
unless comment_or_like.parent.author == user.person || comment_or_like.verify_parent_author_signature
|
||||||
|
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
#check to make sure the signature of the comment or like comes from the person claiming to authoring said comment or like
|
#as the owner of the post being liked or commented on, you need to add your own signature in order to pass it to the people who received your original post
|
||||||
unless comment_or_like.parent.author == user.person || comment_or_like.verify_parent_author_signature
|
if user.owns? comment_or_like.parent
|
||||||
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}")
|
comment_or_like.parent_author_signature = comment_or_like.sign_with_key(user.encryption_key)
|
||||||
return
|
comment_or_like.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
#as the owner of the post being liked or commented on, you need to add your own signature in order to pass it to the people who received your original post
|
#dispatch object DOWNSTREAM, received it via UPSTREAM
|
||||||
if user.owns? comment_or_like.parent
|
unless user.owns?(comment_or_like)
|
||||||
comment_or_like.parent_author_signature = comment_or_like.sign_with_key(user.encryption_key)
|
comment_or_like.save!
|
||||||
comment_or_like.save!
|
Postzord::Dispatcher.build(user, comment_or_like).post
|
||||||
end
|
end
|
||||||
|
|
||||||
#dispatch object DOWNSTREAM, received it via UPSTREAM
|
comment_or_like.socket_to_user(user) if comment_or_like.respond_to? :socket_to_user
|
||||||
unless user.owns?(comment_or_like)
|
|
||||||
comment_or_like.save!
|
|
||||||
Postzord::Dispatcher.build(user, comment_or_like).post
|
|
||||||
end
|
|
||||||
|
|
||||||
comment_or_like.socket_to_user(user) if comment_or_like.respond_to? :socket_to_user
|
if comment_or_like.after_receive(user, person)
|
||||||
|
comment_or_like
|
||||||
if comment_or_like.after_receive(user, person)
|
|
||||||
comment_or_like
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue