aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2025-01-10 18:57:46 +0800
committerHsieh Chin Fan <pham@topo.tw>2025-01-10 18:57:46 +0800
commit59c7600782b9b9ba5b879484795257bce95b1ce0 (patch)
treebf4a3d04192302e0f4b80d1c8bfe4b1ef61b13e4
parente8554fdbb21094fdf8cc1aa1c43ecb48f2f35b29 (diff)
Update deliver.sh
-rwxr-xr-xbin/mail/deliver.sh22
1 files changed, 14 insertions, 8 deletions
diff --git a/bin/mail/deliver.sh b/bin/mail/deliver.sh
index 134e4fd..d0ab6b8 100755
--- a/bin/mail/deliver.sh
+++ b/bin/mail/deliver.sh
@@ -26,7 +26,7 @@ tmp_mailbox=$(mktemp -d); mkdir -p ${tmp_mailbox}/{tmp,new,cur}
26cat >${tmp_mailbox}/cur/mail 26cat >${tmp_mailbox}/cur/mail
27trap 'rm -rf ${tmp_mailbox}' EXIT 27trap 'rm -rf ${tmp_mailbox}' EXIT
28 28
29# Restore mail into variables 29# Restore mail into vars
30MAIL="$(decodemail ${tmp_mailbox})" 30MAIL="$(decodemail ${tmp_mailbox})"
31# TODO process multi-line header field 31# TODO process multi-line header field
32header="$(<<<"$MAIL" sed '/^$/ q; /^[[:blank:]]/ d;')" 32header="$(<<<"$MAIL" sed '/^$/ q; /^[[:blank:]]/ d;')"
@@ -59,7 +59,7 @@ while IFS=': ' read field value; do
59done <<<"$header" 59done <<<"$header"
60 60
61# save to mailbox 61# save to mailbox
62if [[ "$SENDER" = pham@topo.tw && -n $Chat_Version ]]; then 62if [[ "$SENDER" = pham@topo.tw && -n $CHAT_VERSION ]]; then
63 heading="$(head -1 <<<"${body}")" 63 heading="$(head -1 <<<"${body}")"
64 64
65 if [[ "${heading}" =~ ^"." ]]; then 65 if [[ "${heading}" =~ ^"." ]]; then
@@ -80,25 +80,31 @@ if [[ "$SENDER" = pham@topo.tw && -n $Chat_Version ]]; then
80 $(sed 1d <<<"$body") 80 $(sed 1d <<<"$body")
81 MAIL 81 MAIL
82 } 82 }
83elif [[ "$FROM" =~ notifications@github.com || "$RETURN_PATH" =~ noreply@github.com ]]; then
84 mailbox=DEV/github
83elif [[ "$SUBJECT" =~ 帳單|轉帳|對帳|付款|發票|消費|繳費|收據|費用|Invoice|Billing ]]; then 85elif [[ "$SUBJECT" =~ 帳單|轉帳|對帳|付款|發票|消費|繳費|收據|費用|Invoice|Billing ]]; then
84 mailbox=pay 86 mailbox=pay
85elif [[ "$TO" = dmarc@topo.tw ]]; then 87elif [[ "$SUBJECT" =~ 未讀|unread ]]; then
88 mailbox=update
89elif [[ "$TO" =~ dmarc@topo.tw ]]; then
86 mailbox=DEV/dmarc 90 mailbox=DEV/dmarc
87elif [[ "$LIST_ID" =~ ^'Open Street Map Taiwan' ]]; then 91elif [[ "$LIST_ID" =~ ^'Open Street Map Taiwan' ]]; then
88 mailbox=FOSS/osm 92 mailbox=FOSS/osm
93elif [[ "$TO" =~ talk-ja@openstreetmap.org ]]; then
94 mailbox=LIST/talk-ja
89elif [[ "$LIST_ID" =~ ^~rjarry/aerc-discuss ]]; then 95elif [[ "$LIST_ID" =~ ^~rjarry/aerc-discuss ]]; then
90 mailbox=LIST/aerc 96 mailbox=LIST/aerc
91elif [[ "$LIST_ID" =~ '<mutt-users.mutt.org>' ]]; then 97elif [[ "$LIST_ID" =~ '<mutt-users.mutt.org>' ]]; then
92 mailbox=LIST/mutt 98 mailbox=LIST/mutt
93elif [[ -n "${LIST_ID}" ]]; then 99elif [[ -n "${LIST_ID}" || "$SUBJECT" =~ 電子報|newsletter|快訊 ]]; then
94 mailbox=news 100 mailbox=news
95elif [[ "$SUBJECT" =~ login|verify|sign-in|密碼|安全性警示|登入 ]]; then 101elif [[ "$SUBJECT" =~ login|verify|sign-in|密碼|安全性警示|登入 ]]; then
96 mailbox=login 102 mailbox=login
97elif [[ "$SUBJECT" =~ 電子報|newsletter ]]; then
98 mailbox=news
99elif [[ "$TO" = cloudflare@topo.tw ]]; then 103elif [[ "$TO" = cloudflare@topo.tw ]]; then
100 mailbox=SRV/cloudflare 104 mailbox=SRV/cloudflare
101elif [[ "$SUBJECT" =~ eDM ]]; then 105elif [[ "$SUBJECT" =~ summary ]]; then
106 mailbox=update
107elif [[ "${SUBJECT}${FROM}" =~ eDM ]]; then
102 mailbox=MISC/promote 108 mailbox=MISC/promote
103fi 109fi
104 110
@@ -106,4 +112,4 @@ fi
106set_stdout && print_mail 112set_stdout && print_mail
107 113
108# log to stderr 114# log to stderr
109echo -e ${date} ${mailbox:-INBOX} '\t' ${heading:-${SUBJECT}} >&2 115echo -e ${date} ${mailbox:-INBOX} '\t' "${heading:-${SUBJECT}}" >&2