aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/mail-notify.sh
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-13 18:26:47 +0200
committerDanilo M. <danix@danix.xyz>2026-09-13 18:26:47 +0200
commit1a01efb088df07cae3f517e69940392606d00d94 (patch)
treeeff67bf588b6bd479cf10127bde760fadd551a7b /mail-overview/mail-notify.sh
parent2eb373726a0abe07741138616a9e2bc70a2f753b (diff)
downloadquickshell-1a01efb088df07cae3f517e69940392606d00d94.tar.gz
quickshell-1a01efb088df07cae3f517e69940392606d00d94.zip
fix(mail-overview): don't re-notify the prior batch, flatten newlines
The lastmod range is inclusive at both ends and the stored revision was reused as the next start, so the batch just notified matched again. Start one revision later. A subject can contain a newline, which broke the bullet rows and the +N more count; flatten CR/LF to a space before escaping. Also reconciles the state-write comment and spec with the actual skip-and-advance failure behavior, and corrects two doc wordings.
Diffstat (limited to 'mail-overview/mail-notify.sh')
-rwxr-xr-xmail-overview/mail-notify.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/mail-overview/mail-notify.sh b/mail-overview/mail-notify.sh
index e6c9868..b132775 100755
--- a/mail-overview/mail-notify.sh
+++ b/mail-overview/mail-notify.sh
@@ -25,7 +25,7 @@
#
# Usage:
# mail-notify.sh watch forever (what autostart runs)
-# mail-notify.sh --once process one tick and exit (what the test drives)
+# mail-notify.sh --once process one tick and exit (for manual verification, one tick)
set -u
@@ -104,6 +104,7 @@ build_body() {
rowtext="$(printf '%s' "$json" | jq -r '
.[] | "• " + ((.authors // "(unknown)") + " — " + (.subject // "(no subject)"))
+ | gsub("[\r\n]+"; " ")
| gsub("&"; "&amp;") | gsub("<"; "&lt;") | gsub(">"; "&gt;")
' 2>/dev/null)" || return 0
[[ -n "$rowtext" ]] || return 0
@@ -231,7 +232,7 @@ tick() {
while IFS=$'\t' read -r key label; do
[[ -n "$key" ]] || continue
- query="$SCOPE and tag:account-$key and lastmod:$prev..$cur"
+ query="$SCOPE and tag:account-$key and lastmod:$((prev + 1))..$cur"
count="$(notmuch count "$query" 2>/dev/null)"
# Same validation, same reason: an empty string must not become a
@@ -245,9 +246,10 @@ tick() {
notify_account "$label" "$key" "$count" "$(build_body "$rows" "$count")"
done < <(parse_accounts < "$CONFIG")
- # Written only after every account is done, so a failure part way through
- # leaves prev unchanged and the next tick retries rather than dropping a
- # batch silently.
+ # Written only after every account is done. A single account whose count
+ # fails to validate is skipped above but does not hold the revision back;
+ # leaving it behind would re-notify every successful account's range on
+ # each later tick. Only a failed state write itself leaves prev unchanged.
write_state "$uuid" "$cur"
}