SF.net SVN: postfixadmin:[1372] trunk/VIRTUAL_VACATION/vacation.pl
Brought to you by:
christian_boltz,
gingerdog
From: <Gin...@us...> - 2012-04-19 21:19:21
|
Revision: 1372 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1372&view=rev Author: GingerDog Date: 2012-04-19 21:19:15 +0000 (Thu, 19 Apr 2012) Log Message: ----------- merge of patch from maharaja - delete old vacation_notifications - see https://sourceforge.net/tracker/?func=detail&aid=3323227&group_id=191583&atid=937966 Modified Paths: -------------- trunk/VIRTUAL_VACATION/vacation.pl Modified: trunk/VIRTUAL_VACATION/vacation.pl =================================================================== --- trunk/VIRTUAL_VACATION/vacation.pl 2012-04-19 21:10:42 UTC (rev 1371) +++ trunk/VIRTUAL_VACATION/vacation.pl 2012-04-19 21:19:15 UTC (rev 1372) @@ -272,6 +272,16 @@ sub already_notified { my ($to, $from) = @_; my $logger = get_logger(); + + # delete old notifications + my $query = qq{DELETE vacation_notification.* FROM vacation_notification LEFT JOIN vacation ON vacation.email = vacation_notification.on_vacation WHERE on_vacation = ? AND notified = ? AND notified_at < vacation.activefrom}; + my $stm = $dbh->prepare($query); + if (!$stm) { + $logger->error("Could not prepare query (trying to delete old vacation notifications) :'$query' to: $to, from:$from"); + return 1; + } + $stm->execute($to,$from); + my $query = qq{INSERT into vacation_notification (on_vacation,notified) values (?,?)}; my $stm = $dbh->prepare($query); if (!$stm) { @@ -347,18 +357,18 @@ my $rv = check_for_vacation($email); # Recipient has vacation - if ($rv == 1) { - $realemail = $email; - $logger->debug("Found '$email' has vacation active"); - } else { - my $vemail = $email; - $vemail =~ s/\@/#/g; - $vemail = $vemail . "\@" . $vacation_domain; - $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on"); - my $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ? OR goto = ?)}; - my $stm = $dbh->prepare($query) or panic_prepare($query); - $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); - $rv = $stm->rows; + if ($rv == 1) { + $realemail = $email; + $logger->debug("Found '$email' has vacation active"); + } else { + my $vemail = $email; + $vemail =~ s/\@/#/g; + $vemail = $vemail . "\@" . $vacation_domain; + $logger->debug("Looking for alias records that '$email' resolves to with vacation turned on"); + my $query = qq{SELECT goto FROM alias WHERE address=? AND (goto LIKE ? OR goto LIKE ? OR goto LIKE ? OR goto = ?)}; + my $stm = $dbh->prepare($query) or panic_prepare($query); + $stm->execute($email,"$vemail,%","%,$vemail","%,$vemail,%", "$vemail") or panic_execute($query,"address='$email'"); + $rv = $stm->rows; # Recipient is an alias, check if mailbox has vacation @@ -636,5 +646,3 @@ 0; #/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |