Fix the rake task and importer instead
This commit is contained in:
parent
ee18d9ace0
commit
341836eb42
|
@ -890,12 +890,12 @@ module Email
|
|||
|
||||
def create_post_with_attachments(options = {})
|
||||
# deal with attachments
|
||||
options[:raw] = add_attachments(options[:raw], options[:user].id, options)
|
||||
options[:raw] = add_attachments(options[:raw], options[:user], options)
|
||||
|
||||
create_post(options)
|
||||
end
|
||||
|
||||
def add_attachments(raw, user_id, options = {})
|
||||
def add_attachments(raw, user, options = {})
|
||||
rejected_attachments = []
|
||||
attachments.each do |attachment|
|
||||
tmp = Tempfile.new(["discourse-email-attachment", File.extname(attachment.filename)])
|
||||
|
@ -904,7 +904,7 @@ module Email
|
|||
File.open(tmp.path, "w+b") { |f| f.write attachment.body.decoded }
|
||||
# create the upload for the user
|
||||
opts = { for_group_message: options[:is_group_message] }
|
||||
upload = UploadCreator.new(tmp, attachment.filename, opts).create_for(user_id)
|
||||
upload = UploadCreator.new(tmp, attachment.filename, opts).create_for(user.id)
|
||||
if upload&.valid?
|
||||
# try to inline images
|
||||
if attachment.content_type&.start_with?("image/")
|
||||
|
|
|
@ -277,7 +277,7 @@ task 'posts:refresh_emails', [:topic_id] => [:environment] do |_, args|
|
|||
receiver = Email::Receiver.new(post.raw_email)
|
||||
|
||||
body, elided = receiver.select_body
|
||||
body = receiver.add_attachments(body || '', post.user_id)
|
||||
body = receiver.add_attachments(body || '', post.user)
|
||||
body << Email::Receiver.elided_html(elided) if elided.present?
|
||||
|
||||
post.revise(Discourse.system_user, { raw: body, cook_method: Post.cook_methods[:regular] },
|
||||
|
|
|
@ -131,7 +131,8 @@ module ImportScripts::Mbox
|
|||
|
||||
if row['attachment_count'].positive?
|
||||
receiver = Email::Receiver.new(row['raw_message'])
|
||||
body = receiver.add_attachments(body, user_id)
|
||||
user = User.find(user_id)
|
||||
body = receiver.add_attachments(body, user)
|
||||
end
|
||||
|
||||
body << Email::Receiver.elided_html(elided) if elided.present?
|
||||
|
|
Loading…
Reference in New Issue