• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat/GeneralChat.php
  • Класс: BitrixImV2ChatGeneralChat
  • Вызов: GeneralChat::getGeneralChatId
static function getGeneralChatId(): ?int
{
	$cache = static::getCache(self::ID_CACHE_ID);

	$cachedId = $cache->getVars();

	if ($cachedId !== false)
	{
		return $cachedId ?? 0;
	}

	$result = ChatTable::query()
		->setSelect(['ID'])
		->where('TYPE', Chat::IM_TYPE_OPEN)
		->where('ENTITY_TYPE', Chat::ENTITY_TYPE_GENERAL)
		->fetch() ?: []
	;

	$chatId = $result['ID'] ?? null;
	$cache->startDataCache();
	$cache->endDataCache($chatId);

	return $chatId ?? 0;
}