• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/managers/pushwatchingmanager.php
  • Класс: BitrixCalendarSyncManagersPushWatchingManager
  • Вызов: PushWatchingManager::renewSectionPush
private function renewSectionPush(Push $pushChannel): void
{
	$sectionLink = $this->getLinkFactory()->getSectionConnection([
		'filter' => [
			'=ID' => $pushChannel->getEntityId(),
		]
	]);
	if (
		$sectionLink !== null
		&& $sectionLink->isActive()
		&& ($sectionLink->getConnection() !== null)
		&& !$sectionLink->getConnection()->isDeleted()
	)
	{
		/** @var FactoryInterface $vendorFactory */
		$vendorFactory = $this->getFactoryByConnection($sectionLink->getConnection());
		/** @var PushManagerInterface $vendorPushManager */
		if ($vendorPushManager = $vendorFactory->getPushManager())
		{
			$now = new DateTime();
			if ($pushChannel->getExpireDate()->getDate() > $now)
			{
				$result = $this->renewPushChannel($vendorPushManager, $pushChannel);
				if ($result->isSuccess())
				{
					return;
				}
				elseif ($result->getErrorCollection()->getErrorByCode(405))
				{
					$result = $this->recreateSectionPushChannel($vendorPushManager, $pushChannel, $sectionLink);
					if ($result->isSuccess())
					{
						return;
					}
				}
				elseif ($result->getErrorCollection()->getErrorByCode(401))
				{
					return;
				}
			}
			else
			{
				$result = $this->recreateSectionPushChannel($vendorPushManager, $pushChannel, $sectionLink);
				if ($result->isSuccess())
				{
					return;
				}
			}
		}
	}

	$this->deleteChannel($pushChannel);
}