From d2f2caef9b51e38bc5e9501db7fd1fcd84b36b46 Mon Sep 17 00:00:00 2001 From: wmorgan Date: Tue, 28 Aug 2007 21:46:53 +0000 Subject: [PATCH] improve mime-decode hook with sibling_types variable git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@548 5c8cc53c-5e98-4d25-b20a-d8db53a31250 --- lib/sup/message.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/sup/message.rb b/lib/sup/message.rb index ffcde9e..812d743 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -21,9 +21,12 @@ class Message HookManager.register "mime-decode", < content_type, - :filename => lambda { write_to_disk } + :filename => lambda { write_to_disk }, :sibling_types => sibling_types @lines = text.split("\n") if text end end @@ -323,9 +326,10 @@ private ## of the gruesome slaughterhouse and sausage factory that is a ## mime-encoded message, but need only see the delicious end ## product. - def message_to_chunks m + def message_to_chunks m, sibling_types=[] if m.multipart? - m.body.map { |p| message_to_chunks p }.flatten.compact # recurse + sibling_types = m.body.map { |p| p.header.content_type } + m.body.map { |p| message_to_chunks p, sibling_types }.flatten.compact # recurse else filename = ## first, paw through the headers looking for a filename @@ -344,7 +348,7 @@ private ## if there's a filename, we'll treat it as an attachment. if filename - [Attachment.new(m.header.content_type, filename, m)] + [Attachment.new(m.header.content_type, filename, m, sibling_types)] ## otherwise, it's body text else -- 2.45.2