From 9551828cd214519a5c3b95c1d3747a0a4788a470 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sun, 23 Sep 2007 20:58:20 +0200 Subject: [PATCH 1/1] first implementation of delayed queue --- procmail/defines | 2 +- procmail/delay-delivery | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/procmail/defines b/procmail/defines index c38adab..a544089 100644 --- a/procmail/defines +++ b/procmail/defines @@ -76,7 +76,7 @@ RE_EXTRACT_HEADER_VALUE="$RE_SPACE*\/$RE_NOT_SPACE.*" DEJAVU_HEADER=X-Deja-Vu NULL=/dev/null -DELAY_QUEUE=$BASE/.delay/ +DELAYED_QUEUE=$BASE/.delayed/ TICKLER_QUEUE=$BASE/.tickler/ DISCARD=$BASE/.discard/ #DISCARD="'|$DELIVER -m BASE.discard'" diff --git a/procmail/delay-delivery b/procmail/delay-delivery index e69de29..e04f7d7 100644 --- a/procmail/delay-delivery +++ b/procmail/delay-delivery @@ -0,0 +1,34 @@ +:0 +* ^X-Mailer: swaks +{ DELAY="30 seconds" } + +# create table messages (msgid text unique not null, filename text +# primary key not null unique, release_ts integer not null); + +:0 +* DELAY ?? . +{ + #TODO: for tickling, use header date + RELEASE="`date -d \"now + $DELAY\" +'%s %c'`" + :0 + *$ RELEASE ?? ^\/${RE_NOT_SPACE}+ + { RELEASE_TS=$MATCH } + :0 + *$ RELEASE ?? ^[0-9]+${RE_SPACE}+\/.+ + { RELEASE_TIME="$MATCH" } + + LOG="delay: delay delivery of $MSGID until $RELEASE_TIME$NL" + + DELAYED_QUEUE_DB=$PMVAR/delayed-queue.sqlite + DO_QUERY="$SQLITE $DELAYED_QUEUE_DB" + + DATA="$MSGID" + INCLUDERC=$PMDIR/sql-escape + + Q="insert into messages values + ($DATA, '\\'\$DESTFILE\\'', $RELEASE_TS)" + TRAP="$TRAP; $DO_QUERY '$Q'" + + :0 + $DELAYED_QUEUE +} -- 2.39.5