diff --git a/lib/tasks/posts.rake b/lib/tasks/posts.rake index 144a92e8656..b57d4cf9af1 100644 --- a/lib/tasks/posts.rake +++ b/lib/tasks/posts.rake @@ -250,13 +250,19 @@ task 'posts:refresh_emails', [:topic_id] => [:environment] do |_, args| total = posts.count posts.find_each do |post| - receiver = Email::Receiver.new(post.raw_email) + begin + receiver = Email::Receiver.new(post.raw_email) - body, elided = receiver.select_body - body = receiver.add_attachments(body || '', post.user_id) - body << Email::Receiver.elided_html(elided) if elided.present? + body, elided = receiver.select_body + body = receiver.add_attachments(body || '', post.user_id) + body << Email::Receiver.elided_html(elided) if elided.present? + + post.revise(Discourse.system_user, { raw: body, cook_method: Post.cook_methods[:regular] }, + skip_revision: true, skip_validations: true, bypass_bump: true) + rescue + puts "Failed to refresh post (topic_id: #{post.topic_id}, post_id: #{post.id})" + end - post.revise(Discourse.system_user, { raw: body }, skip_revision: true, skip_validations: true) updated += 1 print_status(updated, total)