]> git.notmuchmail.org Git - sup/commitdiff
overwrite from and to fields in index when saving a message
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 25 Mar 2009 15:49:56 +0000 (08:49 -0700)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Wed, 25 Mar 2009 15:49:56 +0000 (08:49 -0700)
See comments in the code. This allows you to forcibly update the from/to
address stored in the index for messages, which means you can correct
the bad stuff stored in there due to previous versions of Sup that
canonicalized email addresses.

lib/sup/index.rb

index 9addc6505bf1e20b7f84b18883b03ffc43f55604..838d601347f1f86ffba21ac72e37c3e191ac95ba 100644 (file)
@@ -246,8 +246,17 @@ EOS
       :snippet => snippet, # always override
       :label => labels.uniq.join(" "),
       :attachments => (entry[:attachments] || m.attachments.uniq.join(" ")),
-      :from => (entry[:from] || (m.from ? m.from.indexable_content : "")),
-      :to => (entry[:to] || (m.to + m.cc + m.bcc).map { |x| x.indexable_content }.join(" ")),
+
+      ## always override :from and :to.
+      ## older versions of Sup would often store the wrong thing in the index
+      ## (because they were canonicalizing email addresses, resulting in the
+      ## wrong name associated with each.) the correct address is read from
+      ## the original header when these messages are opened in thread-view-mode,
+      ## so this allows people to forcibly update the address in the index by
+      ## marking those threads for saving.
+      :from => (m.from ? m.from.indexable_content : ""),
+      :to => (m.to + m.cc + m.bcc).map { |x| x.indexable_content }.join(" "),
+
       :subject => (entry[:subject] || wrap_subj(Message.normalize_subj(m.subj))),
       :refs => (entry[:refs] || (m.refs + m.replytos).uniq.join(" ")),
     }