# HG changeset patch # User HIROSE Yuuji # Date 1587115046 -32400 # Node ID 962c954715b88fbb339b0c151edd3559df988337 # Parent 51e0cc07a79aebbeae1115ec1fc8fe43fc216523 smail_queue() initially implemented diff -r 51e0cc07a79a -r 962c954715b8 s4-funcs.sh --- a/s4-funcs.sh Fri Apr 17 18:15:40 2020 +0900 +++ b/s4-funcs.sh Fri Apr 17 18:17:26 2020 +0900 @@ -13,6 +13,7 @@ dbdir=${DBDIR:-db} tmpfiles="" db=${DB:-$dbdir/cgi.sq3} +workdb=$dbdir/tmpdata.sq3 listentlimit=${LISTENTLIMIT:-30} admin=${ADMIN:-hostmaster@example.org} noreply=${NOREPLY:-noreply@example.org} @@ -1145,6 +1146,68 @@ (_m4 -D_RCPT_="${SMAIL_TO:-$rcpt}" -D_SUBJ_="\`$subj'" -D_FROM_="$from" $msgdir/mail-header.m4 cat $3 | nkf -jd ) | sendmail -f $admin $rcpt } +smail_queue_flush() { + # $1=timelimit + timelimit=`sq $workdb "SELECT datetime('now', 'localtime', '-1 minutes');"` + err timelimit="$timelimit" rowid=$rowid + err r===="$(sq $workdb <<-EOF + SELECT rowid FROM smailq + GROUP BY rcpts, subj + HAVING min(time) < '$timelimit'; + EOF + )" + rowids=$(sq $workdb <<-EOF + SELECT rowid FROM smailq + GROUP BY rcpts, subj + HAVING min(time) < '$timelimit'; + EOF + ) + for rid in $rowids; do + sq $workdb \ + "SELECT hex(rcpts),hex(subj) FROM smailq WHERE rowid in ($rid)" \ + | if IFS='|' read hexr hexs; then + err "hexrcpt=[$hexr] hexsubj=[$hexs]" + rcpt=`echo "$hexr"|unhexize` + subj=`echo "$hexs"|unhexize` + + # err ROWID==$rowid "sql=<