• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/controller/call/beta.php
  • Класс: BitrixImControllerCallBeta
  • Вызов: Beta::createRoomAction
public function createRoomAction(CurrentUser $currentUser, string $dialogId = "0", int $chatId = 0)
{
	if ($dialogId > 0)
	{
		$chatId = Dialog::getChatId($dialogId, $currentUser->getId());
	}
	if ($chatId <= 0)
	{
		$this->addError(new Error("You must be specified chatId or dialogId"));
		return null;
	}

	$chat = Chat::getInstance($chatId);

	if (!$chat->hasAccess())
	{
		$this->addError(new Error("You must be a member of the chat to call it"));

		return null;
	}

	$roomId = $chatId.'_'. Alias::generateUnique();
	$link = 'https://demo-stage.webrtc-test.bitrix.info/?roomId='.$roomId;

	$text = Loc::getMessage("IM_CALL_BETA_INVITE", [
		'#LINK#' => '[URL='.$link.']'.Loc::getMessage('IM_CALL_BETA_INVITE_BUTTON').'[/URL]',
	]);

	$message = new Message();
	$message->setMessage($text)->markAsImportant(true);
	$message->getParams()
		->fill([
			Params::COMPONENT_ID => 'CallInviteMessage',
			Params::COMPONENT_PARAMS => [
				'LINK' => $link
			]
		])
		->save()
	;
	$chat->sendMessage($message);

	return true;
}