2017-04-27 18:51:18 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-06-28 09:29:53 +02:00
|
|
|
addtag() { notmuch tag +"$1" -- "tag:new and ($2) and not tag:$1"; }
|
|
|
|
archive() { notmuch tag -new -unread -- "$@" and tag:new; }
|
|
|
|
spam() { notmuch tag -new -unread +spam -- "$@" and '(' tag:new or tag:unread or not tag:spam ')'; }
|
|
|
|
|
|
|
|
# Tag mails by their origin (top-level maildir)
|
|
|
|
for maildir in /data/mail/*; do
|
|
|
|
origin="$(basename "$maildir")"
|
|
|
|
addtag "$origin" "folder:/$origin/"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Spam
|
|
|
|
spam "subject:/^\[SPAM\]/"
|
|
|
|
# TODO: Known spammers
|
|
|
|
|
|
|
|
# Some aliases
|
|
|
|
addtag zeus "to:felixvdj@zeus.ugent.be"
|
|
|
|
addtag dodona "to:dodona@ugent.be"
|
|
|
|
addtag unipept "to:unipept@ugent.be"
|
|
|
|
|
2020-05-13 10:59:19 +02:00
|
|
|
# These mails tend to be numerous and do not need additional tagging
|
|
|
|
archive tag:dodona subject:"Mysql2::Error: Table 'dodona.active_storage_blobs' doesn't exist"
|
|
|
|
archive tag:dodona subject:'A request took'
|
|
|
|
archive tag:dodona subject:'Errno::ENOENT'
|
|
|
|
archive tag:unipept subject:'Mysql2::Error::ConnectionError'
|
|
|
|
archive tag:unipept subject:'invalid value for Integer'
|
|
|
|
archive tag:unipept subject:'NoMethodError'
|
|
|
|
|
2019-06-28 09:29:53 +02:00
|
|
|
# More complex tagging
|
|
|
|
for mid in $(notmuch search --output=messages tag:new); do
|
|
|
|
|
|
|
|
tag=false
|
|
|
|
|
|
|
|
# +-tags become actual tags
|
|
|
|
for tag in $(notmuch show --format=raw "$mid" | sed -n '/^\tfor/s/.*<[^>]*+\([^@]*\)@.*>.*/\1/p' | sort | uniq); do
|
|
|
|
addtag "$tag" "$mid"
|
|
|
|
tag=true
|
|
|
|
done
|
|
|
|
|
|
|
|
# messages from contacts get a contact tag
|
|
|
|
for sender in $(notmuch address --output=sender --output=address "$mid"); do
|
|
|
|
if khard list "$sender" > /dev/null 2>&1; then
|
|
|
|
addtag contact "$mid"
|
|
|
|
tag=true
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# mails to posteo must have a tag
|
|
|
|
if ! "$tag"; then
|
|
|
|
addtag killed "$mid and tag:posteo"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# list ids
|
|
|
|
for list in $(notmuch show --format=raw "$mid" | sed -n '/^List-Id:/,/^\w/p' | sed '$d' | tr '\n' ' ' | sed 's/[^<]*<// ; s/\..*//'); do
|
|
|
|
addtag "lists" "$mid"
|
|
|
|
addtag "lists/$list" "$mid"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2020-01-06 21:19:58 +01:00
|
|
|
# Undelay threads with new messages
|
|
|
|
for delaytag in $(notmuch search --output=tags -- tag:delay and thread:{tag:new} | grep 'delay/'); do
|
|
|
|
notmuch tag -delay -"$delaytag" +inbox -- tag:"$delaytag" and thread:{tag:new}
|
2019-10-16 14:47:22 +02:00
|
|
|
done
|
|
|
|
|
2019-08-02 10:12:48 +02:00
|
|
|
# Github notifications
|
|
|
|
addtag github "from:notifications@github.com"
|
|
|
|
|
2019-06-28 09:29:53 +02:00
|
|
|
# Uninteresting
|
2019-11-21 15:12:59 +01:00
|
|
|
archive tag:dodona subject:'Onderwijsinstelling aangemaakt voor .*'
|
|
|
|
archive tag:dodona from:'logcheck system account'
|
2020-05-13 10:59:19 +02:00
|
|
|
archive tag:dodona from:'KlasCement'
|
2020-01-08 12:08:26 +01:00
|
|
|
archive tag:dodona subject:'Een gebruiker kon niet inloggen'
|
2020-09-25 10:24:25 +02:00
|
|
|
archive tag:dodona subject:faraday::connectionfailed
|
2020-08-20 15:55:49 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'course_id: 317' # C testcursus 2020-2021
|
2020-09-22 11:03:35 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'course_id: 335' # R basic 2020-2021
|
2020-09-25 10:24:25 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'course_id: 375' # Statistiek: introductie tot R 2020-2021
|
2020-09-22 11:03:35 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'course_id: 380' # C# 2020-2021
|
2020-09-25 10:24:25 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'course_id: 384' # E620500A 2020-2021
|
2020-04-15 00:37:13 +02:00
|
|
|
archive tag:dodona subject:'status was changed to internal error' 'user_id: 3' # Peter
|
2019-11-21 15:12:59 +01:00
|
|
|
archive tag:github thread:{from:dependabot} \
|
|
|
|
-subject:Security \
|
|
|
|
-to:mention@noreply.github.com \
|
|
|
|
-to:assign@noreply.github.com \
|
|
|
|
-to:review_requested@noreply.github.com \
|
|
|
|
-to:security_alert@noreply.github.com
|
2020-08-20 15:55:49 +02:00
|
|
|
archive tag:ugent subject:'Belnet FileSender: Ontvangstbevestiging'
|
2019-08-27 22:09:21 +02:00
|
|
|
|
2020-01-08 12:08:26 +01:00
|
|
|
# Muted threads stay muted for a month after arrival
|
2020-01-06 21:22:53 +01:00
|
|
|
archive thread:{tag:muted}
|
2020-01-08 12:08:26 +01:00
|
|
|
notmuch tag -muted -- tag:muted and date:'..30_days'
|
2019-06-28 09:29:53 +02:00
|
|
|
|
|
|
|
# Inbox remaining not-spam
|
|
|
|
addtag inbox "not tag:spam"
|
|
|
|
notmuch tag -new -- tag:new
|
2019-10-16 14:47:22 +02:00
|
|
|
|
2020-01-06 21:19:58 +01:00
|
|
|
# Show threads after their delay
|
2019-10-16 14:47:22 +02:00
|
|
|
today="$(date +'%s')"
|
2020-01-06 21:19:58 +01:00
|
|
|
for delaytag in $(notmuch search --output=tags tag:delay | grep 'delay/'); do
|
|
|
|
until="$(date -d "${delaytag#*/}" +'%s')"
|
2019-10-16 14:47:22 +02:00
|
|
|
if [ "$today" -gt "$until" ]; then
|
2020-01-08 12:08:26 +01:00
|
|
|
notmuch tag -delay -"$delaytag" +inbox -- tag:"$delaytag"
|
2019-10-16 14:47:22 +02:00
|
|
|
fi
|
2019-11-21 15:12:59 +01:00
|
|
|
done
|