mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-19 17:38:06 +02:00
* Mail: limit async notification on new mail to once every 3 minutes; control if a imapHost is set on choosen profile
This commit is contained in:
parent
7434cd7144
commit
080a4ac653
@ -607,6 +607,15 @@ class mail_hooks
|
|||||||
*/
|
*/
|
||||||
static function notification_check_mailbox()
|
static function notification_check_mailbox()
|
||||||
{
|
{
|
||||||
|
// should not run more often then every 3 minutes;
|
||||||
|
$lastRun = egw_cache::getCache(egw_cache::INSTANCE,'email','mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*24*2);
|
||||||
|
$currentTime = time();
|
||||||
|
if (!empty($lastRun) && $lastRun>$currentTime-3*60)
|
||||||
|
{
|
||||||
|
|
||||||
|
error_log(__METHOD__.__LINE__." Job should not run too often; we limit this to once every 3 Minutes :". ($currentTime-$lastRun). " Seconds to go!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
$accountsToSearchObj = emailadmin_account::search($only_current_user=true, $just_name=true);
|
$accountsToSearchObj = emailadmin_account::search($only_current_user=true, $just_name=true);
|
||||||
|
|
||||||
foreach($accountsToSearchObj as $acc_id => $identity_name)
|
foreach($accountsToSearchObj as $acc_id => $identity_name)
|
||||||
@ -638,14 +647,13 @@ class mail_hooks
|
|||||||
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed.'.$e->getMessage());
|
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed.'.$e->getMessage());
|
||||||
continue; //fail silently
|
continue; //fail silently
|
||||||
}
|
}
|
||||||
/*
|
//error_log(__METHOD__.__LINE__.' '.$nFKey.' =>'.array2string($bomail->icServer->params));
|
||||||
error_log(__METHOD__.__LINE__.' '.$nFKey.' =>'.array2string($bomail->icServer));
|
$icServerParams=$bomail->icServer->params;
|
||||||
if (empty($bomail->icServer->acc_imap_host))
|
if (empty($icServerParams['acc_imap_host']))
|
||||||
{
|
{
|
||||||
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed: NO IMAP HOST configured!');
|
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed: NO IMAP HOST configured!');
|
||||||
continue; //fail silently
|
continue; //fail silently
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$bomail->openConnection($activeProfile);
|
$bomail->openConnection($activeProfile);
|
||||||
@ -727,6 +735,7 @@ class mail_hooks
|
|||||||
error_log(__METHOD__.__LINE__.' Notification on new messages for Profile '.$activeProfile.' ('.$accountsToSearchArray[$activeProfile].') failed:'.$e->getMessage());
|
error_log(__METHOD__.__LINE__.' Notification on new messages for Profile '.$activeProfile.' ('.$accountsToSearchArray[$activeProfile].') failed:'.$e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
egw_cache::setCache(egw_cache::INSTANCE,'email','mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']),time(), $expiration=60*60*24*2);
|
||||||
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user