add support for inline images in emails in
This commit is contained in:
parent
478062ba71
commit
dd28a3c63a
|
@ -122,15 +122,12 @@ module Email
|
||||||
|
|
||||||
def select_body(message)
|
def select_body(message)
|
||||||
html = nil
|
html = nil
|
||||||
# If the message is multipart, return that part (favor html)
|
|
||||||
if message.multipart?
|
|
||||||
html = fix_charset message.html_part
|
|
||||||
text = fix_charset message.text_part
|
|
||||||
|
|
||||||
# prefer plain text
|
if message.multipart?
|
||||||
if text
|
text = fix_charset message.text_part
|
||||||
return text
|
# prefer text over html
|
||||||
end
|
return text if text
|
||||||
|
html = fix_charset message.html_part
|
||||||
elsif message.content_type =~ /text\/html/
|
elsif message.content_type =~ /text\/html/
|
||||||
html = fix_charset message
|
html = fix_charset message
|
||||||
end
|
end
|
||||||
|
@ -247,7 +244,13 @@ module Email
|
||||||
# create the upload for the user
|
# create the upload for the user
|
||||||
upload = Upload.create_for(user.id, tmp, attachment.filename, tmp.size)
|
upload = Upload.create_for(user.id, tmp, attachment.filename, tmp.size)
|
||||||
if upload && upload.errors.empty?
|
if upload && upload.errors.empty?
|
||||||
# TODO: should use the same code as the client to insert attachments
|
# try to inline images
|
||||||
|
if attachment.content_type.start_with?("image/")
|
||||||
|
if raw =~ /\[image: Inline image \d+\]/
|
||||||
|
raw.sub!(/\[image: Inline image \d+\]/, attachment_markdown(upload))
|
||||||
|
next
|
||||||
|
end
|
||||||
|
end
|
||||||
raw << "\n#{attachment_markdown(upload)}\n"
|
raw << "\n#{attachment_markdown(upload)}\n"
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
|
Loading…
Reference in New Issue