• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/controller/call.php
  • Класс: BitrixImControllerCall
  • Вызов: Call::tryJoinCallAction
public function tryJoinCallAction($type, $provider, $entityType, $entityId)
{
	$currentUserId = $this->getCurrentUser()->getId();
	$call = CallFactory::searchActive($type, $provider, $entityType, $entityId, $currentUserId);
	if(!$call)
	{
		return [
			'success' => false
		];
	}

	if(!$call->getAssociatedEntity()->checkAccess($currentUserId))
	{
		$this->errorCollection[] = new Error("You can not access this call", 'access_denied');
		return null;
	}

	if(!$call->hasUser($currentUserId))
	{
		$addedUser = $call->addUser($currentUserId);
		if(!$addedUser)
		{
			$this->errorCollection[] = new Error("User limit reached",  "user_limit_reached");
			return null;
		}
		$call->getSignaling()->sendUsersJoined($currentUserId, [$currentUserId]);
	}

	return [
		'success' => true,
		'call' => $call->toArray(),
		'connectionData' => $call->getConnectionData($currentUserId),
		'logToken' => $call->getLogToken($currentUserId)
	];
}