- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::messageShare
static function messageShare($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);
}
if (!BitrixImCommon::isDialogId($arParams['DIALOG_ID']))
{
throw new BitrixRestRestException("Dialog ID can't be empty", "DIALOG_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
}
if (!BitrixImDialog::hasAccess($arParams['DIALOG_ID']))
{
throw new BitrixRestRestException("You do not have access to the specified dialog", "ACCESS_ERROR", CRestServer::STATUS_FORBIDDEN);
}
$chatId = BitrixImDialog::getChatId($arParams['DIALOG_ID']);
if (!$chatId)
{
throw new BitrixRestRestException("You don't have access to this chat", "ACCESS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$result = CIMMessenger::Share($arParams['ID'], $arParams['TYPE']);
if ($result === false)
{
throw new BitrixRestRestException("Incorrect params", "PARAMS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
return true;
}