Re: whitelisting

Subject: Re: whitelisting

Date: Mon, 06 Mar 2017 16:06:38 -0800

To: notmuch@notmuchmail.org

Cc:

From: Jameson Graef Rollins


On Mon, Mar 06 2017, Jameson Graef Rollins <jrollins@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.
signature.asc (application/pgp-signature)

Thread: