42 'lastFailedToSyncMailboxId' => 0,
43 'hasSuccessSync' =>
false,
47 if (Loader::includeModule(
'mail') && is_object($USER) && $USER->IsAuthorized())
49 $userId = $USER->GetID();
51 $mailboxesReadyToSync = $mailboxesSyncManager->getNeedToBeSyncedMailboxes();
53 if (!empty($mailboxesReadyToSync))
55 foreach ($mailboxesReadyToSync as $mailboxId => $lastMailCheckData)
57 $mailboxHelper = Helper\Mailbox::createInstance($mailboxId,
false);
58 if (!empty($mailboxHelper))
60 if ($mailboxHelper->sync() ===
false)
62 $result[
'lastFailedToSyncMailboxId'] = $mailboxId;
66 $result[
'hasSuccessSync'] =
true;
68 if ($mailboxHelper->getMailbox()[
'SYNC_LOCK'] >= 0)
74 $unseen = max(
Helper\Message::getCountersForUserMailboxes($userId,
true), 0);
75 $result[
'unseen'] = $unseen;
76 \CUserCounter::set($userId,
'mail_unseen', $unseen, SITE_ID);