Rename inbox to flag to sync it and bogofilter spam

This commit is contained in:
Felix Van der Jeugt 2020-11-14 14:36:43 +01:00
parent 0030cd4860
commit 3915f133fd
No known key found for this signature in database
GPG Key ID: 58B209295023754D
6 changed files with 42 additions and 36 deletions

View File

@ -1,5 +1,5 @@
initial_command = search tag:inbox
initial_command = search tag:flagged
periodic_hook_frequency = 60
edit_headers_blacklist = Content-Type, MIME-Version
attachment_prefix = /data/temporary
@ -21,7 +21,7 @@ theme = "mutt"
sendmail_command = /usr/bin/msmtp --account=posteo -t
sent_box = maildir:///data/mail/posteo/Sent
draft_box = maildir:///data/mail/posteo/Drafts
sent_tags = posteo,inbox
sent_tags = posteo,flagged
passed_tags = # none
sign_by_default = False
@ -38,7 +38,7 @@ theme = "mutt"
sendmail_command = /usr/bin/msmtp --account=gmail -t
sent_box = maildir:///data/mail/gmail/Sent
draft_box = maildir:///data/mail/gmail/Sent
sent_tags = gmail,inbox
sent_tags = gmail,flagged
passed_tags = # none
sign_by_default = True
@ -56,7 +56,7 @@ theme = "mutt"
sendmail_command = /usr/bin/msmtp --account=ugent -t
sent_box = maildir:///data/mail/ugent/Sent
draft_box = maildir:///data/mail/ugent/Sent
sent_tags = ugent,inbox
sent_tags = ugent,flagged
passed_tags = # none
sign_by_default = True
@ -72,7 +72,7 @@ theme = "mutt"
sendmail_command = true
sent_box = maildir:///data/mail/todo
draft_box = maildir:///data/mail/todo
sent_tags = todo,inbox
sent_tags = todo,flagged
passed_tags = # none
@ -82,9 +82,8 @@ theme = "mutt"
n = compose --sender todo@localhost --to todo
[[search]]
x = toggletags spam,inbox
a = toggletags inbox
A = toggletags inbox,muted
a = toggletags flagged
A = toggletags flagged,muted
1 = call hooks.delay(ui,1)
2 = call hooks.delay(ui,2)
3 = call hooks.delay(ui,3)
@ -96,10 +95,11 @@ theme = "mutt"
9 = call hooks.delay(ui,9)
0 = call hooks.delay(ui,0)
i = call hooks.spam(ui)
x = call hooks.togglespam(ui)
[[thread]]
a = toggletags inbox ; fold
A = toggletags inbox,muted ; fold
a = toggletags flagged ; fold
A = toggletags flagged,muted ; fold
n = togglemimepart
r = reply --all
u = pipeto --background selecturl
@ -117,7 +117,7 @@ theme = "mutt"
[tags]
[[inbox]]
[[flagged]]
translated =
[[encrypted]]

View File

@ -15,20 +15,20 @@ async def delay(ui, days):
if days != 0:
for message in messages:
if 'inbox' in message.get_tags():
if 'flagged' in message.get_tags():
message.add_tags(['delay', datetag])
await ui.apply_commandline('untag inbox,unread')
await ui.apply_commandline('untag flagged,unread')
else:
for message in messages:
if 'delay' in message.get_tags():
message.remove_tags([t for t in message.get_tags() if t.startswith('delay')])
message.add_tags(['inbox'])
message.add_tags(['flagged'])
await ui.apply_commandline('untag delay,delay/*')
async def spam(ui):
message = ui.current_buffer.get_selected_message()
message.add_tags(['spam'])
message.remove_tags(['unread', 'inbox'])
message.remove_tags(['unread', 'flagged'])
if 'ugent' in message.get_tags():
envelope = Envelope(
headers=dict(

View File

@ -1,15 +1,13 @@
#!/bin/sh
set -e
mid="id:$1"
file="$(notmuch show "$mid" | sed -n '1s/.*filename:\([^ ]*\).*/\1/p')"
temp="$(mktemp)"
cat > "$temp" <<HERE
References: <$1>
HERE
alot compose --sender felix.vanderjeugt@ugent.be \
--template="$temp" \
--subject spam \
--to spam@ugent.be \
--attach "$file"
for mid in $(notmuch search --output=messages tag:inbox "$@"); do
printf "%s ? " "$(notmuch show "$mid" | sed -n 's/Subject: //p')"
read ans
case "$ans" in
y*)
notmuch show --format=raw "$mid" | bogofilter -Sn
notmuch tag -inbox -unread +spam -- "$mid"
;;
esac
done

View File

@ -88,4 +88,4 @@ exclude_tags=spam;
synchronize_flags=true
[query]
inbox=tag:inbox
inbox=tag:flagged

View File

@ -10,10 +10,6 @@ for maildir in /data/mail/*; do
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"
@ -60,7 +56,7 @@ done
# 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}
notmuch tag -delay -"$delaytag" +flagged -- tag:"$delaytag" and thread:{tag:new}
done
# Github notifications
@ -78,7 +74,9 @@ archive tag:dodona subject:'status was changed to internal error' 'course_id: 33
archive tag:dodona subject:'status was changed to internal error' 'course_id: 339' # Data Mining 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 346' # Programming Basics 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 349' # Programmingin Python 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 374' # Statistiek 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 375' # Statistiek: introductie tot R 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 376' # Statistiek: Data Exploratie .. 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 380' # C# 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'course_id: 384' # E620500A 2020-2021
archive tag:dodona subject:'status was changed to internal error' 'user_id: 3' # Peter
@ -94,8 +92,17 @@ archive tag:ugent subject:'Belnet FileSender: Ontvangstbevestiging'
archive thread:{tag:muted}
notmuch tag -muted -- tag:muted and date:'..30_days'
# Bogofilter
for mid in $(notmuch search --output=messages tag:new); do
case "$(notmuch show --format=raw "$mid" | bogofilter -eut)" in
H*) true ;;
S*) spam "$mid" ; echo "$mid" >> ~/spamtest;;
U*) true ;;
esac
done
# Inbox remaining not-spam
addtag inbox "not tag:spam"
addtag flagged "not tag:spam"
notmuch tag -new -- tag:new
# Show threads after their delay
@ -103,6 +110,6 @@ today="$(date +'%s')"
for delaytag in $(notmuch search --output=tags tag:delay | grep 'delay/'); do
until="$(date -d "${delaytag#*/}" +'%s')"
if [ "$today" -gt "$until" ]; then
notmuch tag -delay -"$delaytag" +inbox -- tag:"$delaytag"
notmuch tag -delay -"$delaytag" +flagged -- tag:"$delaytag"
fi
done

View File

@ -24,6 +24,7 @@ export LESSHISTFILE=-
export FZF_DEFAULT_COMMAND='(git ls-files -co --exclude-standard || rg --files) 2> /dev/null'
export SKIM_DEFAULT_COMMAND='(git ls-files -co --exclude-standard || rg --files) 2> /dev/null'
export LC_ALL=en_US.utf8
export BOGOFILTER_DIR="$XDG_DATA_HOME/bogofilter"
# Select Dock sound card if it's there
#(it's broken)