FIX: Sidekiq job has wrong data when post owner changes within transaction
This commit is contained in:
parent
79590e4bec
commit
80e85e0d8f
|
@ -11,19 +11,17 @@ class PostOwnerChanger
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_owner!
|
def change_owner!
|
||||||
ActiveRecord::Base.transaction do
|
@post_ids.each do |post_id|
|
||||||
@post_ids.each do |post_id|
|
post = Post.with_deleted.where(id: post_id, topic_id: @topic.id).first
|
||||||
post = Post.with_deleted.where(id: post_id, topic_id: @topic.id).first
|
next if post.blank?
|
||||||
next if post.blank?
|
@topic.user = @new_owner if post.is_first_post?
|
||||||
@topic.user = @new_owner if post.is_first_post?
|
|
||||||
|
|
||||||
if post.user == nil
|
if post.user == nil
|
||||||
@topic.recover! if post.is_first_post?
|
@topic.recover! if post.is_first_post?
|
||||||
end
|
|
||||||
post.topic = @topic
|
|
||||||
post.set_owner(@new_owner, @acting_user, @skip_revision)
|
|
||||||
PostAction.remove_act(@new_owner, post, PostActionType.types[:like])
|
|
||||||
end
|
end
|
||||||
|
post.topic = @topic
|
||||||
|
post.set_owner(@new_owner, @acting_user, @skip_revision)
|
||||||
|
PostAction.remove_act(@new_owner, post, PostActionType.types[:like])
|
||||||
|
|
||||||
@topic.update_statistics
|
@topic.update_statistics
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue