• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/googleapipush.php
  • Класс: BitrixCalendarSyncGoogleApiPush
  • Вызов: GoogleApiPush::startChannelForInActiveSections
static function startChannelForInActiveSections(
	array $localSections,
	array $inactiveSections,
	GoogleApiSync $googleApiConnection
): void
{
	foreach ($localSections as $section)
	{
		if (self::isVirtualCalendar($section['GAPI_CALENDAR_ID'], $section['EXTERNAL_TYPE']))
		{
			continue;
		}

		if (isset($inactiveSections[$section['ID']]))
		{
			if (($push = self::getPush(self::TYPE_SECTION, $section['ID'])) && self::isValid($push))
			{
				continue;
			}

			$channelInfo = $googleApiConnection->startWatchEventsChannel($section['GAPI_CALENDAR_ID']);
			if ($channelInfo && isset($channelInfo['id'], $channelInfo['resourceId']))
			{
				self::deletePushChannel(
					[
						"ENTITY_TYPE" => self::TYPE_SECTION,
						'ENTITY_ID' => $section['ID']
					]
				);
				$googleApiConnection->updateSuccessLastResultConnection();
				PushTable::add([
					'ENTITY_TYPE' => self::TYPE_SECTION,
					'ENTITY_ID' => $section['ID'],
					'CHANNEL_ID' => $channelInfo['id'],
					'RESOURCE_ID' => $channelInfo['resourceId'],
					'EXPIRES' => $channelInfo['expiration'],
					'NOT_PROCESSED' => 'N'
				]);
			}
			else
			{
				$error = $googleApiConnection->getTransportConnectionError();
				if (is_string($error))
				{
					$googleApiConnection->updateLastResultConnection($error);
				}
			}
		}
	}
}