unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jameson Graef Rollins <jrollins@finestructure.net>
To: notmuch@notmuchmail.org
Subject: Re: whitelisting
Date: Mon, 06 Mar 2017 16:06:38 -0800	[thread overview]
Message-ID: <87efyavtkh.fsf@ligo.caltech.edu> (raw)
In-Reply-To: <87innmvvam.fsf@ligo.caltech.edu>

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

      parent reply	other threads:[~2017-03-07  0:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-06 23:29 whitelisting Jameson Graef Rollins
2017-03-07  0:02 ` whitelisting Steven Allen
2017-03-07  0:23   ` whitelisting Jameson Graef Rollins
2017-03-07  0:06 ` Jameson Graef Rollins [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efyavtkh.fsf@ligo.caltech.edu \
    --to=jrollins@finestructure.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).