- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::chatMute
static function chatMute($arParams, $n, CRestServer $server)
{
$arParams = array_change_key_case($arParams, CASE_UPPER);
if (isset($arParams['DIALOG_ID']))
{
if (BitrixImCommon::isChatId($arParams['DIALOG_ID']))
{
$arParams['CHAT_ID'] = BitrixImDialog::getChatId($arParams['DIALOG_ID']);
}
else
{
throw new BitrixRestRestException("Dialog ID can't be empty", "DIALOG_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
}
}
$arParams['CHAT_ID'] = intval($arParams['CHAT_ID']);
if ($arParams['CHAT_ID'] <= 0)
{
throw new BitrixRestRestException("Chat ID can't be empty", "CHAT_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
}
if (!Chat::isActionAllowed('chat' . $arParams['CHAT_ID'], 'MUTE'))
{
throw new BitrixRestRestException('This chat cannot be muted', 'ACCESS_ERROR', CRestServer::STATUS_FORBIDDEN);
}
if (isset($arParams['ACTION']))
{
$arParams['MUTE'] = $arParams['ACTION'];
}
return BitrixImChat::mute($arParams['CHAT_ID'], $arParams['MUTE'] != 'N');
}