clone of my dotfiles.ssp.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix screening

sspaeti 0fb1d15a e5e1ee0e

+39 -18
+39 -18
mutt/.config/mutt/notmuch/notmuch_screening.sh
··· 68 68 printf "Tagging remaining new emails as to-screen...\n" 69 69 notmuch tag +to-screen -new -- tag:new and not tag:screened-in and not tag:screened-out and not tag:feed and not tag:papertrail 70 70 71 - # Move previously screened emails if sender status changed 72 - printf "Updating tags for emails in to-screen based on current lists...\n" 71 + # Efficiently process to-screen emails against current lists 72 + printf "Processing to-screen emails against screening lists...\n" 73 + 74 + # Process screened_in list against to-screen emails (most efficient: bulk operations) 75 + while IFS= read -r email; do 76 + [ -z "$email" ] && continue 77 + count=$(notmuch count from:"$email" tag:to-screen) 78 + if [ "$count" -gt 0 ]; then 79 + printf " Screening in %d emails from %s\n" "$count" "$email" 80 + notmuch tag +screened-in +inbox -to-screen -- from:"$email" tag:to-screen 81 + fi 82 + done < "$screened_in" 83 + 84 + # Process screened_out list against to-screen emails 85 + while IFS= read -r email; do 86 + [ -z "$email" ] && continue 87 + count=$(notmuch count from:"$email" tag:to-screen) 88 + if [ "$count" -gt 0 ]; then 89 + printf " Screening out %d emails from %s\n" "$count" "$email" 90 + notmuch tag +screened-out +spam -to-screen -inbox -- from:"$email" tag:to-screen 91 + fi 92 + done < "$screened_out" 73 93 74 - # Check to-screen emails and retag if sender is now in a list 75 - for msg_id in $(notmuch search --output=messages tag:to-screen); do 76 - sender=$(notmuch show --format=json "$msg_id" | grep -o '"From":.*"' | head -1 | grep -Eo '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}') 94 + # Process feed list against to-screen emails 95 + while IFS= read -r email; do 96 + [ -z "$email" ] && continue 97 + count=$(notmuch count from:"$email" tag:to-screen) 98 + if [ "$count" -gt 0 ]; then 99 + printf " Tagging %d emails from %s as feed\n" "$count" "$email" 100 + notmuch tag +feed -to-screen -inbox -- from:"$email" tag:to-screen 101 + fi 102 + done < "$feed_list" 77 103 78 - if grep -Fxq "$sender" "$screened_in"; then 79 - notmuch tag +screened-in +inbox -to-screen -- id:"$msg_id" 80 - printf "Moved %s back to inbox (screened-in)\n" "$msg_id" 81 - elif grep -Fxq "$sender" "$screened_out"; then 82 - notmuch tag +screened-out +spam -to-screen -inbox -- id:"$msg_id" 83 - printf "Tagged %s as screened-out\n" "$msg_id" 84 - elif grep -Fxq "$sender" "$feed_list"; then 85 - notmuch tag +feed -to-screen -inbox -- id:"$msg_id" 86 - printf "Tagged %s as feed\n" "$msg_id" 87 - elif grep -Fxq "$sender" "$papertrail_list"; then 88 - notmuch tag +papertrail -to-screen -inbox -- id:"$msg_id" 89 - printf "Tagged %s as papertrail\n" "$msg_id" 104 + # Process papertrail list against to-screen emails 105 + while IFS= read -r email; do 106 + [ -z "$email" ] && continue 107 + count=$(notmuch count from:"$email" tag:to-screen) 108 + if [ "$count" -gt 0 ]; then 109 + printf " Tagging %d emails from %s as papertrail\n" "$count" "$email" 110 + notmuch tag +papertrail -to-screen -inbox -- from:"$email" tag:to-screen 90 111 fi 91 - done 112 + done < "$papertrail_list" 92 113 93 114 printf "Notmuch screening completed at $(date '+%Y-%m-%d %H:%M:%S')\n" 94 115 printf -- "####################################\n"