• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/controller/call.php
  • Класс: BitrixImControllerCall
  • Вызов: Call::getUserStateAction
public function getUserStateAction($callId, int $userId = 0)
{
	$currentUserId = (int)$this->getCurrentUser()->getId();
	$call = Registry::getCallWithId($callId);

	if(!$call || !$this->checkCallAccess($call, $currentUserId))
	{
		$this->errorCollection[] = new Error("Call is not found or you do not have access to the call", "access_denied");
		return null;
	}

	if ($userId === 0)
	{
		$userId = $currentUserId;
	}

	$lockName = static::getLockNameWithCallId($callId);
	if (!Application::getConnection()->lock($lockName, static::LOCK_TTL))
	{
		$this->addError(new Error("Could not get exclusive lock", "could_not_lock"));
		return null;
	}

	$callUser = $call->getUser($userId);
	if (!$callUser)
	{
		$this->addError(new Error("User is not part of the call", "unknown_call_user"));
		Application::getConnection()->unlock($lockName);
		return null;
	}

	Application::getConnection()->unlock($lockName);
	return $callUser->toArray();
}