lib/sup/message.rb in sup-0.0.7 vs lib/sup/message.rb in sup-0.0.8

- old
+ new

@@ -136,22 +136,20 @@ @recipient_email = header["envelope-to"] || header["x-original-to"] || header["delivered-to"] @source_marked_read = header["status"] == "RO" end private :read_header - def broken?; @source.broken?; end def snippet; @snippet || chunks && @snippet; end def is_list_message?; !@list_address.nil?; end def is_draft?; DraftLoader === @source; end def draft_filename raise "not a draft" unless is_draft? @source.fn_for_offset @source_info end def save index - return if broken? - index.update_message self if @dirty + index.sync_message self if @dirty @dirty = false end def has_label? t; @labels.member? t; end def add_label t @@ -175,12 +173,12 @@ end ## this is called when the message body needs to actually be loaded. def load_from_source! @chunks ||= - if @source.broken? - [Text.new(error_message(@source.broken_msg.split("\n")))] + if @source.has_errors? + [Text.new(error_message(@source.error.message.split("\n")))] else begin ## we need to re-read the header because it contains information ## that we don't store in the index. actually i think it's just ## the mailing list address (if any), so this is kinda overkill. @@ -190,22 +188,30 @@ ## actually, it's also the differentiation between to/cc/bcc, ## so i will keep this. read_header @source.load_header(@source_info) message_to_chunks @source.load_message(@source_info) rescue SourceError, SocketError, MessageFormatError => e + ## we need force_to_top here otherwise this window will cover + ## up the error message one + Redwood::report_broken_sources :force_to_top => true [Text.new(error_message(e.message))] end end end def error_message msg <<EOS #@snippet... *********************************************************************** -* An error occurred while loading this message. It is possible that * -* the source has changed, or (in the case of remote sources) is down. * + An error occurred while loading this message. It is possible that + the source has changed, or (in the case of remote sources) is down. + You can check the log for errors, though hopefully an error window + should have popped up at some point. + + The message location was: + #@source##@source_info *********************************************************************** The error message was: #{msg} EOS @@ -257,10 +263,10 @@ ## everything RubyMail-specific goes here. def message_to_chunks m ret = [] << case m.header.content_type when "text/plain", nil - m.body && body = m.decode or raise MessageFormatError, "for some bizarre reason, RubyMail was unable to parse this message." + m.body && body = m.decode or raise MessageFormatError, "For some bizarre reason, RubyMail was unable to parse this message." text_to_chunks body.normalize_whitespace.split("\n") when /^multipart\// nil else disp = m.header["Content-Disposition"] || ""