diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 29dfb4089..38d743d18 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -462,34 +462,29 @@ class IncomingMessage < ActiveRecord::Base end else part_filename = TMail::Mail.get_part_file_name(part) - if part.content_type == 'message/rfc822' - # An email attached as text - # e.g. http://www.whatdotheyknow.com/request/64/response/102 - begin + begin + if part.content_type == 'message/rfc822' + # An email attached as text + # e.g. http://www.whatdotheyknow.com/request/64/response/102 part.rfc822_attachment = TMail::Mail.parse(part.body) - rescue - # If attached mail doesn't parse, treat it as text part - part.rfc822_attachment = nil - @count_parts_count += 1 - part.url_part_number = @count_parts_count - else - _count_parts_recursive(part.rfc822_attachment) - end - elsif part.content_type == 'application/vnd.ms-outlook' || part_filename && filename_to_mimetype(part_filename) == 'application/vnd.ms-outlook' - # An email attached as an Outlook file - # e.g. http://www.whatdotheyknow.com/request/chinese_names_for_british_politi - begin + elsif part.content_type == 'application/vnd.ms-outlook' || part_filename && filename_to_mimetype(part_filename) == 'application/vnd.ms-outlook' + # An email attached as an Outlook file + # e.g. http://www.whatdotheyknow.com/request/chinese_names_for_british_politi msg = Mapi::Msg.open(StringIO.new(part.body)) part.rfc822_attachment = TMail::Mail.parse(msg.to_mime.to_s) - rescue - # If attached mail doesn't parse, treat it as text part - part.rfc822_attachment = nil - @count_parts_count += 1 - part.url_part_number = @count_parts_count - else - _count_parts_recursive(part.rfc822_attachment) + elsif part.content_type == 'application/ms-tnef' + # A set of attachments in a TNEF file + part.rfc822_attachment = TNEF.as_tmail(part.body) end + rescue + # If attached mail doesn't parse, treat it as text part + part.rfc822_attachment = nil else + unless part.rfc822_attachment.nil? + _count_parts_recursive(part.rfc822_attachment) + end + end + if part.rfc822_attachment.nil? @count_parts_count += 1 part.url_part_number = @count_parts_count end @@ -815,7 +810,7 @@ class IncomingMessage < ActiveRecord::Base curr_mail.content_type = 'text/plain' end end - if curr_mail.content_type == 'application/vnd.ms-outlook' + if curr_mail.content_type == 'application/vnd.ms-outlook' || curr_mail.content_type == 'application/ms-tnef' ensure_parts_counted # fills in rfc822_attachment variable if curr_mail.rfc822_attachment.nil? # Attached mail didn't parse, so treat as binary @@ -824,7 +819,7 @@ class IncomingMessage < ActiveRecord::Base end # If the part is an attachment of email - if curr_mail.content_type == 'message/rfc822' || curr_mail.content_type == 'application/vnd.ms-outlook' + if curr_mail.content_type == 'message/rfc822' || curr_mail.content_type == 'application/vnd.ms-outlook' || curr_mail.content_type == 'application/ms-tnef' ensure_parts_counted # fills in rfc822_attachment variable leaves_found += _get_attachment_leaves_recursive(curr_mail.rfc822_attachment, curr_mail.rfc822_attachment) else |