summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2014-12-26 18:39:12 (GMT)
committer Jaromil <jaromil@dyne.org>2014-12-26 18:39:12 (GMT)
commit65eb80e8f884f11663066963368eb131b931b609 (patch)
tree0c43e711ab841ef9db152335c8a2faa70516cff1
parent3e5d8243ddc78134ab5d8dbc18fdf8a660157130 (diff)
sieve filter creation adapted to new addressbookabook
-rw-r--r--src/zlibs/filters60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/zlibs/filters b/src/zlibs/filters
index 213a8a5..7139af6 100644
--- a/src/zlibs/filters
+++ b/src/zlibs/filters
@@ -523,22 +523,22 @@ require ["fileinto","mailbox","variables"];
EOF
# blacklist
- sieve_filter_array=()
- newlock "$TMPDIR/blacklist.sieve.$id"
- cat <<EOF | ${SQL} -batch ${addressbook} \
- >> "$TMPDIR/blacklist.sieve.$id"
-SELECT email FROM blacklist;
-EOF
- for i in `cat "$TMPDIR/blacklist.sieve.$id"`; do
- sieve_filter_array+=("$i"); done
- unlink "$TMPDIR/blacklist.sieve.$id"
-
- { test "${#sieve_filter_array}" = "0" } || {
- sieve_filter \
- 'if header :contains "From"' \
- zz.blacklist
+ [[ -r "$MAILDIRS"/blacklist.abook ]] && {
+ sieve_filter_array=()
+
+ for i in `awk -F'=' '
+/^email/ { print $2 }
+' "$MAILDIRS"/blacklist.abook`; do
+ sieve_filter_array+=("$i")
+ done
+
+ { test "${#sieve_filter_array}" = "0" } || {
+ sieve_filter \
+ 'if header :contains "From"' \
+ zz.blacklist
+ }
}
-
+
# bounces
cat <<EOF >> "$MAILDIRS/Filters.sieve"
# bounces
@@ -568,24 +568,20 @@ EOF
act "compiling whitelist rules from addressbook"
func "generating whitelist for sieve filters"
- sieve_filter_array=()
- newlock "$TMPDIR/whitelist.sieve.$id"
- cat <<EOF | ${SQL} -batch ${addressbook} \
- >> "$TMPDIR/whitelist.sieve.$id"
-SELECT email FROM whitelist;
-
-EOF
-
- for i in `cat "$TMPDIR/whitelist.sieve.$id"`; do
- sieve_filter_array+=("$i"); done
-
- unlink "$TMPDIR/whitelist.sieve.$id"
-
- sieve_filter \
- 'if header :contains "From"' \
- INBOX
+ [[ -r "$MAILDIRS"/whitelist.abook ]] && {
+ sieve_filter_array=()
+ for i in `awk -F'=' '
+/^email/ { print $2 }
+' "$MAILDIRS"/whitelist.abook`; do
+ sieve_filter_array+=("$i")
+ done
- cat <<EOF >> "$MAILDIRS/Filters.sieve"
+ sieve_filter \
+ 'if header :contains "From"' \
+ INBOX
+ }
+
+ cat <<EOF >> "$MAILDIRS/Filters.sieve"
# spam
if header :is "X-Spam-Flag" "YES" {
fileinto :create "zz.spam"; stop;