• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/sync/googleapipush.php
  • Класс: BitrixCalendarSyncGoogleApiPush
  • Вызов: GoogleApiPush::processIncomingPush
static function processIncomingPush(string $entityType, int $entityId)
{
	global $DB;
	if ($entityType === self::TYPE_SECTION)
	{
		$r = $DB->query(
			"SELECT s.*, c.LAST_RESULT as LAST_RESULT 
								FROM b_calendar_section s
								LEFT JOIN b_dav_connections c 
									ON s.CAL_DAV_CON = c.ID
								WHERE s.ID=" . $entityId
		);
		if ($section = $r->fetch())
		{
			if (self::isAuthError($section['LAST_RESULT']))
			{
				return;
			}

			$tokens = [];
			if (!empty($tokens))
			{
				if (empty($tokens['nextSyncToken']))
				{
					QueueManager::setIntervalForAgent(QueueManager::PERMANENT_UPDATE_TIME, QueueManager::PERMANENT_UPDATE_TIME);
				}

				CCalendarSect::edit(
					[
						'arFields' =>
							[
								'ID' => $section['ID'],
								'SYNC_TOKEN' => $tokens['nextSyncToken'],
								'PAGE_TOKEN' => $tokens['nextPageToken'],
							]
					]
				);
			}

			CCalendar::clearCache();
		}
	}
	elseif ($entityType === self::TYPE_CONNECTION)
	{
		$r = $DB->query("SELECT * FROM b_dav_connections WHERE ID=" . $entityId);
		if ($connection = $r->fetch())
		{
			if (
				self::isAuthError($connection['LAST_RESULT'])
				|| !Loader::includeModule('dav')
			)
			{
				return;
			}

//				CCalendarSync::syncConnection($connection);
			CCalendar::clearCache();
		}
	}
}