• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/controller/call.php
  • Класс: BitrixImControllerCall
  • Вызов: Call::sendPrecallInviteMessage
protected function sendPrecallInviteMessage($entityId, $entityType, $call): bool
{
	$settings = BitrixMainConfigConfiguration::getValue('im');
	$betaWebUrl  = $settings['call']['beta_web_url'] ?? '';

	if (empty($betaWebUrl))
	{
		return false;
	}

	$currentUserId = $this->getCurrentUser()->getId();

	$chatId = null;
	if($entityType === EntityType::CHAT && (Common::isChatId($entityId) || (int)$entityId > 0))
	{
		$chatId = Dialog::getChatId($entityId, $currentUserId);
	}

	if (is_null($chatId))
	{
		return false;
	}

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

	$link = $betaWebUrl . '/?roomId=' . $call->getUuid();
	$text = Loc::getMessage("IM_BITRIX_CALL_INVITE_TEMP", [
		'#LINK#' => '[URL=' . $link . ']' . Loc::getMessage('IM_BITRIX_CALL_INVITE_BUTTON_TEMP') . '[/URL]',
	]);

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

	return true;
}