• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Service/Messenger.php
  • Класс: BitrixImV2ServiceMessenger
  • Вызов: Messenger::getEntityChat
public function getEntityChat(string $entityType, string $entityId): Chat
{
	$chatFactory = ChatFactory::getInstance();
	$chat = $chatFactory
		->setContext($this->context)
		->getEntityChat($entityType, $entityId)
	;

	if (!$chat)
	{
		return (new NullChat())
			->setPreparedParams([
				'TYPE' => Chat::IM_TYPE_CHAT,
				'ENTITY_TYPE' => $entityType,
				'ENTITY_ID' => $entityId,
			]);
	}

	if (!$chat->hasAccess())
	{
		return new NullChat();
	}

	return $chat;
}