Method: PostDestroyer#user_recovered

Defined in:
lib/post_destroyer.rb

#user_recoveredObject



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/post_destroyer.rb', line 269

def user_recovered
  return unless @post.user_deleted?

  Post.transaction do
    @post.update_column(:user_deleted, false)
    @post.skip_unique_check = true
    @post.topic.update_column(:closed, false) if @post.is_first_post?
  end

  # has internal transactions, if we nest then there are some very high risk deadlocks
  last_revision = @post.revisions.last
  if last_revision.present? && last_revision.modifications["raw"].present?
    @post.revise(@user, { raw: last_revision.modifications["raw"][0] }, force_new_version: true)
  end
end