- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::messageCommand
static function messageCommand($arParams, $n, CRestServer $server)
{
$arParams = array_change_key_case($arParams, CASE_UPPER);
if (isset($arParams['MESSAGE_ID']))
{
$arParams['ID'] = $arParams['MESSAGE_ID'];
}
$arParams['ID'] = intval($arParams['ID']);
if ($arParams['ID'] <= 0)
{
throw new BitrixRestRestException("Message ID can't be empty", "MESSAGE_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$arParams['BOT_ID'] = intval($arParams['BOT_ID']);
if ($arParams['BOT_ID'] <= 0)
{
throw new BitrixRestRestException("Bot ID can't be empty", "BOT_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
if ($arParams['COMMAND'] == '')
{
throw new BitrixRestRestException("Command can't be empty", "COMMAND_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$result = CIMMessenger::ExecCommand($arParams['ID'], $arParams['BOT_ID'], $arParams['COMMAND'], $arParams['COMMAND_PARAMS']);
if ($result === false)
{
throw new BitrixRestRestException("Incorrect params", "PARAMS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
return true;
}