mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-18 12:41:10 +01:00
fixed async job was not removed, if facations was deactivated and only try to reschedule with increasing intervals for 2 days
This commit is contained in:
parent
a66066fbc5
commit
d9ae69e044
@ -507,6 +507,7 @@ class mail_sieve
|
||||
elseif ($content['acc_id'])
|
||||
{
|
||||
$this->account = emailadmin_account::read($content['acc_id']);
|
||||
$preserv['acc_id'] = $content['acc_id'];
|
||||
}
|
||||
|
||||
$icServer = $this->account->imapServer($this->is_admin_vac ? $account_id : false);
|
||||
@ -614,7 +615,8 @@ class mail_sieve
|
||||
// schedule job to switch message on/off, if request and not already in past
|
||||
else
|
||||
{
|
||||
if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time())
|
||||
if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() ||
|
||||
$vacRules && $vacRules['vacation']['status'] == 'by_date')
|
||||
{
|
||||
self::setAsyncJob($newVacation);
|
||||
}
|
||||
@ -694,19 +696,24 @@ class mail_sieve
|
||||
$async->delete($async_id);
|
||||
|
||||
$end_date = $_vacation['end_date'] + 24*3600; // end-date is inclusive, so we have to add 24h
|
||||
if ($_vacation['status'] == 'by_date' && time() < $end_date && $_reschedule===false)
|
||||
if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule)
|
||||
{
|
||||
$time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date;
|
||||
$async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
|
||||
}
|
||||
if ($_reschedule)
|
||||
{
|
||||
$time = time() + 60*3;
|
||||
$_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5;
|
||||
// only try to reschedule for 2 days max
|
||||
if ($_vacation['rescheduled'] <= 2 * 24 * 60)
|
||||
{
|
||||
$time = time() + 60*($_vacation['rescheduled']);
|
||||
unset($_vacation['next']);
|
||||
unset($_vacation['times']);
|
||||
$async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the async job to enable/disable the vacation message
|
||||
@ -728,6 +735,12 @@ class mail_sieve
|
||||
$ret = $icServer->setVacationUser($_vacation['account_id'], null, $_vacation);
|
||||
self::setAsyncJob($_vacation);
|
||||
}
|
||||
// if mail account no longer exists --> remove async job
|
||||
catch (egw_exception_not_found $e)
|
||||
{
|
||||
$_vacation['status'] = 'off';
|
||||
self::setAsyncJob($_vacation);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage());
|
||||
self::setAsyncJob($_vacation, true); // reschedule
|
||||
|
Loading…
Reference in New Issue
Block a user