Bug 166150 - GMail filtering does not work if the message is not moved
Summary: GMail filtering does not work if the message is not moved
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Unmaintained
Component: IMAP (show other bugs)
Version: SVN trunk (KDE 4)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-09 17:14 UTC by Clovis Gladstone
Modified: 2009-04-03 20:53 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Clovis Gladstone 2008-07-09 17:14:05 UTC
Version:            (using Devel)
Installed from:    Compiled sources
OS:                Linux

When I have for example five incoming messages, kmail starts filtering and moves around those messages according to the defined filters. But if, for example, the second message does not have a filter set (and should therefore stay in the main inbox folder), then filtering just stops, leaving the other new messages unfiltered. Kmail should continue filtering the remaining messages even it doesn't find a filter for one specific message.
Another case is when I've set new filters and selected all my messages in my inbox and I run the filters, it stops as soon as it finds a message that doesn't match any filter.
Thanks for your help.
Comment 1 Thomas McGuire 2008-07-09 17:16:28 UTC
Are you using GMail?
Comment 2 Clovis Gladstone 2008-07-09 17:17:10 UTC
This is while using opensuse 4.0.85 packages (I'd selected it in my bug report but somehow it doesn't show up here), so this concerns the brand new kmail.
Comment 3 Clovis Gladstone 2008-07-09 17:17:28 UTC
Yes I am
Comment 4 Thomas McGuire 2008-07-09 17:26:25 UTC
OK, filtering IMAP message which stay in the same folder will simply not work with GMail, because of their idiotic duplicate prevention.
Filtering works the following way:

1. KMail copies the IMAP messages to a local folder
2. KMail filters the message in the local folder
3. KMail moves the filtered message from the local folder to the IMAP folder
4. KMail deletes the original message from the IMAP folder

Because GMail prevents duplicate messages, step 3) will fail (although the new message has an additional header). Please complain about this to Google.

The other problem is that filtering stops when encountering such a problem. This is being worked on, but the patch won't make it into 4.1.
Comment 5 Clovis Gladstone 2008-07-09 17:37:00 UTC
Ok, thanks for looking into this. I'll be sure to complain to google about this. Do you know if the patch you mentioned will be ready for one of the 4.1.x releases ? Thanks again.
Comment 6 Thomas McGuire 2008-07-16 23:08:25 UTC
SVN commit 833475 by tmcguire:

Some fixes for online IMAP filtering:

- In the action scheduler, don't error out when the filtered message
  couldn't be moved back to the target folder. Instead, ignore the error
  (but don't delete the orginal message). This fixes filtering 
  stopping on GMail accounts once a message was encountered that was not
  moved to another folder, but stayed in the same folder (GMail prevents moving
  in this case, since it thinks it is a duplicate message)

- When moving the filtered message with the action scheduler from the
  temporary filter folder to the target folder, the original message wouldn't
  get deleted properly.
  The reason for this was that the move command thought the move failed because
  a message with another serial number arrived.
  Fix this by remembering the serial number (based on the message ID) when using
  the action scheduler for filtering.
  This fixes filters which move messages to other folders: Now the message is properly
  removed from the source folder again.

- add comments and kDebug output

This does _not_ solve the following problem:
When using GMail and online IMAP, filter actions which modify the message will not have
any effect, since GMails duplicate message prevention prevents the filtered message to
be moved back to the IMAP folder.
This will not be fixed, I see no way to work around this. GMail should fix their IMAP
server instead.

Please test, I'm not sure if this is safe to backport.

CCBUG: 166150


 M  +80 -38    actionscheduler.cpp  
 M  +26 -1     actionscheduler.h  
 M  +20 -2     imapjob.cpp  
 M  +7 -0      kmfolderimap.cpp  
 M  +8 -0      kmfolderimap.h  
 M  +1 -1      kmmessage.h  
 M  +1 -1      kmmsgbase.cpp  
 M  +1 -1      kmmsgbase.h  
 M  +1 -1      kmmsginfo.cpp  
 M  +1 -1      kmmsginfo.h  
 M  +20 -0     messageproperty.cpp  
 M  +23 -1     messageproperty.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=833475
Comment 7 Thomas McGuire 2008-07-16 23:09:32 UTC
>Do you know if the patch you mentioned will be ready for one of the 4.1.x releases ? Thanks again. 
Depending on how much testing it gets in trunk, it might even make it into 4.1.0, otherwise into 4.1.1.
Comment 8 Thomas McGuire 2008-07-22 17:21:52 UTC
SVN commit 836580 by tmcguire:

Backport r833475 by tmcguire to the 4.1 branch:

Some fixes for online IMAP filtering:

- In the action scheduler, don't error out when the filtered message
  couldn't be moved back to the target folder. Instead, ignore the error
  (but don't delete the orginal message). This fixes filtering 
  stopping on GMail accounts once a message was encountered that was not
  moved to another folder, but stayed in the same folder (GMail prevents moving
  in this case, since it thinks it is a duplicate message)

- When moving the filtered message with the action scheduler from the
  temporary filter folder to the target folder, the original message wouldn't
  get deleted properly.
  The reason for this was that the move command thought the move failed because
  a message with another serial number arrived.
  Fix this by remembering the serial number (based on the message ID) when using
  the action scheduler for filtering.
  This fixes filters which move messages to other folders: Now the message is properly
  removed from the source folder again.

- add comments and kDebug output

This does _not_ solve the following problem:
When using GMail and online IMAP, filter actions which modify the message will not have
any effect, since GMails duplicate message prevention prevents the filtered message to
be moved back to the IMAP folder.
This will not be fixed, I see no way to work around this. GMail should fix their IMAP
server instead.

Please test, I'm not sure if this is safe to backport.

CCBUG: 166150



 M  +80 -38    actionscheduler.cpp  
 M  +26 -1     actionscheduler.h  
 M  +20 -2     imapjob.cpp  
 M  +7 -0      kmfolderimap.cpp  
 M  +8 -0      kmfolderimap.h  
 M  +1 -1      kmmessage.h  
 M  +1 -1      kmmsgbase.cpp  
 M  +1 -1      kmmsgbase.h  
 M  +1 -1      kmmsginfo.cpp  
 M  +1 -1      kmmsginfo.h  
 M  +20 -0     messageproperty.cpp  
 M  +23 -1     messageproperty.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=836580
Comment 9 Clovis Gladstone 2008-07-22 17:47:13 UTC
thanks a lot for your work. I am unfortunately not able to test this at the moment. But I'll be sure to do it as soon as possible.
Comment 10 Jaime Torres 2009-04-03 20:00:12 UTC
Did you tested it? Does it works for you?
Comment 11 Clovis Gladstone 2009-04-03 20:53:46 UTC
Yes this has been fixed.