• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::diskFolderGet
static function diskFolderGet($arParams, $n, CRestServer $server)
{
	$arParams = array_change_key_case($arParams, CASE_UPPER);

	if (isset($arParams['DIALOG_ID']))
	{
		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);
		}
	}
	else
	{
		$chatId = intval($arParams['CHAT_ID']);

		if ($chatId <= 0)
		{
			throw new BitrixRestRestException("Chat ID can't be empty", "CHAT_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
		}

		if (!BitrixImDialog::hasAccess('chat'.$chatId))
		{
			throw new BitrixRestRestException("You do not have access to the specified dialog", "ACCESS_ERROR", CRestServer::STATUS_FORBIDDEN);
		}
	}

	$folderModel = CIMDisk::GetFolderModel($chatId);
	if (!$folderModel)
	{
		throw new BitrixRestRestException("Internal server error.", "INTERNAL_ERROR", CRestServer::STATUS_INTERNAL);
	}

	return Array(
		'ID' => (int)$folderModel->getId()
	);
}