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

	if (
		!($arParams['SEARCH_TYPE'] ?? null)
		&& !($arParams['SEARCH_DATE'] ?? null)
		&& mb_strlen(trim($arParams['SEARCH_TEXT'])) < 3
	)
	{
		throw new BitrixRestRestException("SEARCH_TEXT can't be less then 3 symbols", "SEARCH_TEXT_ERROR", CRestServer::STATUS_WRONG_REQUEST);
	}

	if (isset($arParams['SEARCH_TEXT']))
	{
		$options['SEARCH_TEXT'] = $arParams['SEARCH_TEXT'];
	}
	if (isset($arParams['SEARCH_TYPE']))
	{
		$options['SEARCH_TYPE'] = $arParams['SEARCH_TYPE'];
	}
	if (isset($arParams['SEARCH_DATE']))
	{
		$options['SEARCH_DATE'] = $arParams['SEARCH_DATE'];
	}
	if (isset($arParams['LAST_ID']))
	{
		if (!preg_match('/^d+$/', $arParams['LAST_ID']))
		{
			throw new BitrixRestRestException(
				"Last notification ID can't be string",
				"LAST_ID_STRING",
				CRestServer::STATUS_WRONG_REQUEST
			);
		}

		$options['LAST_ID'] = (int)$arParams['LAST_ID'];
	}

	if (isset($arParams['LIMIT']))
	{
		$options['LIMIT'] = (int)$arParams['LIMIT'] > 50 ? 50 : (int)$arParams['LIMIT'];
	}
	else
	{
		$options['LIMIT'] = 50;
	}

	$options['CONVERT_TEXT'] = isset($arParams['CONVERT_TEXT']) && $arParams['CONVERT_TEXT'] === 'Y';

	$notify = new BitrixImNotify($options);

	return $notify->search();
}