• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::videoconfPasswordCheck
static function videoconfPasswordCheck($params, $n, CRestServer $server)
{
	$params = array_change_key_case($params, CASE_UPPER);

	if (!$params['PASSWORD'])
	{
		throw new BitrixRestRestException("Password can't be empty", "PASSWORD_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
	}

	if (!$params['ALIAS'])
	{
		throw new BitrixRestRestException("Alias can't be empty", "ALIAS_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
	}

	$conference = BitrixImCallConference::getByAlias($params['ALIAS']);
	if ($conference && $conference->getPassword() === $params['PASSWORD'])
	{
		//create cache for current confId and sessId
		$storage = BitrixMainApplication::getInstance()->getLocalSession('conference_check_' . $conference->getId());
		$storage->set('checked', true);

		//add user to chat
		$currentUserId = BitrixMainEngineCurrentUser::get()->getId();
		$isUserInChat = Chat::isUserInChat($conference->getChatId());
		if ($currentUserId && !$isUserInChat)
		{
			$chat = new CIMChat(0);
			$addingResult = $chat->AddUser($conference->getChatId(), $currentUserId);
			if (!$addingResult)
			{
				throw new BitrixRestRestException("Error during adding user to chat", "ADDING_TO_CHAT_ERROR", CRestServer::STATUS_WRONG_REQUEST);
			}
		}

		return true;
	}

	return false;
}