afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 98 forks source link

filtering does not work as documented #208

Open jefftemplon opened 6 years ago

jefftemplon commented 6 years ago

Hi,

The documentation indicates that one can prevent a message from winding up with tag 'inbox' by removing the 'new' tag before InboxFilter is called. This is not the case; see below where it is demonstrated that the 'new' tag is removed but InboxFilter is still called on the same message.

simeto:Nikhef> afew --tag --new -vvv [ ... ] INFO:afew.filters.BaseFilter.Filter:LHCb Production Manager DEBUG:root:Executing query u"((tag:new)) AND ('from:lhcb-production-manager@cern.ch')" DEBUG:afew.filters.BaseFilter.Filter:Removing tags new from id:201810110917.w9B9H4MN026707@lbvobox106.cern.ch DEBUG:afew.filters.BaseFilter.Filter:Adding tags lhcb-prod-man to id:201810110917.w9B9H4MN026707@lbvobox106.cern.ch INFO:afew.filters.BaseFilter.Filter:Committing changes to 1 messages [ ... ] INFO:afew.filters.InboxFilter.InboxFilter:Retags all messages not tagged as junk or killed as inbox DEBUG:root:Executing query u'((tag:new)) AND ((tag:new))' DEBUG:afew.filters.InboxFilter.InboxFilter:Removing tags new from id:201810110917.w9B9H4MN026707@lbvobox106.cern.ch DEBUG:afew.filters.InboxFilter.InboxFilter:Adding tags inbox to id:201810110917.w9B9H4MN026707@lbvobox106.cern.ch INFO:afew.filters.InboxFilter.InboxFilter:Committing changes to 1 messages

The configuration of the LHCb Production Manager Filter:

[Filter.1] query = 'from:lhcb-production-manager@cern.ch' tags = +lhcb-prod-man;-new message = LHCb Production Manager

Why doesn't this work? Is it a config bug, an afew bug, or a documentation bug?

jefftemplon commented 6 years ago

Strangely enough btw, it does appear to work for the filter defined just underneath:

[Filter.2] query = 'subject:Cron AND from:root' tags = -new;+crond message = Cron messages

Still wonder whether there is a problem with the filter that I can't spot, or is it a problem in the code.

ul commented 2 years ago

I experienced the same issue. I never got time to debug it properly, but removing the inbox tag from new messages before calling afew seems to help:

$ cat ~/mail/.notmuch/hooks/post-new
#!/bin/sh
notmuch tag -inbox -- tag:new
afew --tag --new

I suspect Lieer to add the tag when pulling emails into notmuch: https://github.com/gauteh/lieer/tree/master#translation-between-labels-and-tags