• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/integration/ui/entityselector/chatuserprovider.php
  • Класс: BitrixImIntegrationUIEntitySelectorChatUserProvider
  • Вызов: ChatUserProvider::getChatIdList
static function getChatIdList(string $searchQuery, array $chatTypeList, array $order): array
{
	$query = ChatTable::query();
	$query->addSelect('ID');

	$query->registerRuntimeField(
		'RELATION',
		(new Reference(
			'RELATION',
			RelationTable::class,
			Join::on('this.ID', 'ref.CHAT_ID'),
		))->configureJoinType(Join::TYPE_INNER)
	);

	$query->registerRuntimeField(
		'CHAT_SEARCH',
		(new Reference(
			'CHAT_SEARCH',
			static::getDerivedTableEntity($chatTypeList, $searchQuery),
			Join::on('this.ID', 'ref.CHAT_ID')
		))->configureJoinType(Join::TYPE_INNER)
	);

	$query->where('RELATION.USER_ID', User::getInstance()->getId());
	$query->setOrder($order);
	$query->setLimit(static::MAX_CHATS_IN_SAMPLE);

	$chatIdList = [];
	foreach ($query->exec() as $row)
	{
		$chatIdList[] = (int)$row['ID'];
	}

	return $chatIdList;
}