2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FIX: reply by email can handle emails with attachments. Attachments are still ignored, but a post or topic can be created from the email now.

This commit is contained in:
Neil Lalonde 2014-03-28 09:57:12 -04:00
parent d23585e444
commit fd504e741f
2 changed files with 19 additions and 18 deletions

View file

@ -37,7 +37,7 @@ module Email
def process
raise EmptyEmailError if @raw.blank?
@message = Mail::Message.new(@raw)
@message = Mail.new(@raw)
# First remove the known discourse stuff.
@ -92,13 +92,11 @@ module Email
# If the message is multipart, find the best type for our purposes
if @message.multipart?
@message.parts.each do |p|
if p.content_type =~ /text\/plain/
@body = p.charset ? p.body.decoded.force_encoding(p.charset).encode("UTF-8").to_s : p.body.to_s
return @body
elsif p.content_type =~ /text\/html/
html = p.charset ? p.body.decoded.force_encoding(p.charset).encode("UTF-8").to_s : p.body.to_s
end
if p = @message.text_part
@body = p.charset ? p.body.decoded.force_encoding(p.charset).encode("UTF-8").to_s : p.body.to_s
return @body
elsif p = @message.html_part
html = p.charset ? p.body.decoded.force_encoding(p.charset).encode("UTF-8").to_s : p.body.to_s
end
end
@ -109,6 +107,7 @@ module Email
html = @message.body.to_s
end
end
if html.present?
@body = scrub_html(html)
return @body