sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 568802736e8698f1eb126b7d501c273b878b2bb8
parent 60573298a2258c101a85b3de8121f73d7aec2d51
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Wed, 20 Oct 2010 10:57:02 +0200

Bugfix: Don’t call handle_added_message for old messages with a new location

When sup finds a message, it always called handle_added_message which in turn
invokes add_or_unhide. This is bad, because for killed messages (or marked as
spam), this would bring the message up in the inbox again. After this commit,
handle_added_message is only called when the message is either new or an
existing location of it was updated (to update the labels).

The normal usecase for receiving a message with the same ID is being subscribed
to a mailing list via two different mail addresses.

Diffstat:
M lib/sup/poll.rb | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/sup/poll.rb b/lib/sup/poll.rb
@@ -166,7 +166,13 @@ EOS
           HookManager.run "before-add-message", :message => m
           yield :add, m, old_m if block_given?
           Index.sync_message m, true
-          UpdateManager.relay self, :added, m
+
+          ## We need to add or unhide the message when it either did not exist
+          ## before at all or when it was updated. We do *not* add/unhide when
+          ## the same message was found at a different location
+          if !old_m or not old_m.locations.member? m.location
+            UpdateManager.relay self, :added, m
+          end
         when :delete
           Index.each_message :location => [source.id, args[:info]] do |m|
             m.locations.delete Location.new(source, args[:info])