- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::dialogGet
static function dialogGet($arParams, $offset, CRestServer $server)
{
$arParams = array_change_key_case($arParams, CASE_UPPER);
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 = BitrixImChat::getById($chatId, ['LOAD_READED' => true, 'JSON' => true]);
if (!$result)
{
throw new BitrixRestRestException("You don't have access to this chat", "ACCESS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$result['dialog_id'] = $arParams['DIALOG_ID'];
return $result;
}