X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=lib%2Fsup%2Fmessage.rb;h=f02817a7e4d003263bb4867567f772927648b8ec;hb=8497d187f078a10400079c3d9580d3baa7aece3b;hp=426eb80019c2c7b2015159ceb3413a2d65e1f1ef;hpb=927b7df4b2052a6b3c2ae1f2b44a6bc901315f8d;p=sup diff --git a/lib/sup/message.rb b/lib/sup/message.rb index 426eb80..f02817a 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -127,6 +127,31 @@ class Message @list_unsubscribe = header["list-unsubscribe"] end + ## Expected index entry format: + ## :message_id, :subject => String + ## :date => Time + ## :refs, :replytos => Array of String + ## :from => Person + ## :to, :cc, :bcc => Array of Person + def load_from_index! entry + @id = entry[:message_id] + @from = entry[:from] + @date = entry[:date] + @subj = entry[:subject] + @to = entry[:to] + @cc = entry[:cc] + @bcc = entry[:bcc] + @refs = (@refs + entry[:refs]).uniq + @replytos = entry[:replytos] + + @replyto = nil + @list_address = nil + @recipient_email = nil + @source_marked_read = false + @list_subscribe = nil + @list_unsubscribe = nil + end + def add_ref ref @refs << ref @dirty = true @@ -410,10 +435,19 @@ private chunks elsif m.header.content_type == "message/rfc822" payload = RMail::Parser.read(m.body) - from = payload.header.from.first - from_person = from ? Person.from_address(from.format) : nil - [Chunk::EnclosedMessage.new(from_person, payload.to_s)] + - message_to_chunks(payload, encrypted) + from = payload.header.from.first ? payload.header.from.first.format : "" + to = payload.header.to.map { |p| p.format }.join(", ") + cc = payload.header.cc.map { |p| p.format }.join(", ") + subj = payload.header.subject + subj = subj ? Message.normalize_subj(payload.header.subject.gsub(/\s+/, " ").gsub(/\s+$/, "")) : subj + if Rfc2047.is_encoded? subj + subj = Rfc2047.decode_to $encoding, subj + end + msgdate = payload.header.date + from_person = from ? Person.from_address(from) : nil + to_people = to ? Person.from_address_list(to) : nil + cc_people = cc ? Person.from_address_list(cc) : nil + [Chunk::EnclosedMessage.new(from_person, to_people, cc_people, msgdate, subj)] + message_to_chunks(payload, encrypted) else filename = ## first, paw through the headers looking for a filename