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