aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/mail-notify.sh
diff options
context:
space:
mode:
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"
}