- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::appUnRegister
static function appUnRegister($arParams, $n, CRestServer $server)
{
if ($server->getAuthType() == BitrixRestSessionAuthAuth::AUTH_TYPE)
{
throw new BitrixRestRestException("Access for this method not allowed by session authorization.", "WRONG_AUTH_TYPE", CRestServer::STATUS_FORBIDDEN);
}
$arParams = array_change_key_case($arParams, CASE_UPPER);
$clientId = $server->getClientId();
if (!$clientId)
{
if (!empty($arParams['CLIENT_ID']))
{
$clientId = 'custom'.$arParams['CLIENT_ID'];
}
else
{
throw new BitrixRestAccessException("Client ID not specified");
}
}
$apps = BitrixImApp::getListCache();
if (!isset($apps[$arParams['APP_ID']]))
{
throw new BitrixRestRestException("App not found", "CHAT_APP_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
if ($apps[$arParams['APP_ID']]['APP_ID'] != $clientId)
{
throw new BitrixRestRestException("App was installed by another rest application", "APP_ID_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$result = BitrixImApp::unRegister(Array('ID' => $arParams['APP_ID']));
if (!$result)
{
throw new BitrixRestRestException("App can't be deleted", "WRONG_REQUEST", CRestServer::STATUS_WRONG_REQUEST);
}
return true;
}