whitelisting

Jameson Graef Rollins jrollins at finestructure.net
Mon Mar 6 16:06:38 PST 2017


On Mon, Mar 06 2017, Jameson Graef Rollins <jrollins at finestructure.net> wrote:
> I could try to write a python script to iterate over all tag:spam,
> extract addresses from those messages, and match against the
> whitelist, but I doubt that will be any faster.

So a custom python script that iterates over all tag:new messages and
matches addresses against the white list is actually quite fast, so
hopefully this will be sufficient for my needs:

  query = 'tag:new AND tag:spam'
  me = get_me_addrs()
  whitelist = list(whitelist_iter())
  with notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE) as db:
      query = db.create_query(query)
      for doc in query.search_messages():
          a = match_addr(doc.get_header('From'))
          if a in whitelist:
              db.begin_atomic()
              doc.remove_tag('spam')
              db.end_atomic()

Guess I should have checked that first, so sorry about the noise.  Still
curious if anyone has come up with any other creative solutions to this
issue though...

jamie.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20170306/16d6fcee/attachment.sig>


More information about the notmuch mailing list