FIX: rake task for updating posts received by email should not crash
This commit is contained in:
parent
cafe69caac
commit
b15059418b
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue