• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat/PrivateChat.php
  • Класс: BitrixImV2ChatPrivateChat
  • Вызов: PrivateChat::getCompanion
public function getCompanion(?int $userId = null): BitrixImV2EntityUserUser
{
	$userId = $userId ?? $this->getContext()->getUserId();

	$relations = $this->getRelations(['LIMIT' => 2]);

	if (!$relations->hasUser($userId, $this->getChatId()))
	{
		return new NullUser();
	}

	foreach ($relations as $relation)
	{
		if ($relation->getUserId() !== $userId)
		{
			return $relation->getUser();
		}
	}

	return new NullUser();
}