• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/rest.php
  • Класс: BitrixImOpenLinesRest
  • Вызов: Rest::dialogGet
static function dialogGet($params, $n, CRestServer $server)
{
	$params = array_change_key_case($params, CASE_UPPER);

	if (!Loader::includeModule('im'))
	{
		throw new RestException('Messenger is not installed.', 'IM_NOT_INSTALLED', CRestServer::STATUS_WRONG_REQUEST);
	}

	$chatId = self::getChatId($params);
	if (!$chatId)
	{
		throw new RestException('You do not have access to the specified dialog', 'ACCESS_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	if (!BitrixImOpenLinesChat::hasAccess($chatId))
	{
		throw new RestException('You do not have access to the specified dialog', 'ACCESS_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	$result = ImChat::getById($chatId, ['LOAD_READED' => true, 'JSON' => true]);
	if (!$result)
	{
		throw new RestException('You do not have access to the specified dialog', 'ACCESS_ERROR', CRestServer::STATUS_WRONG_REQUEST);
	}

	$result['dialog_id'] = 'chat'.$chatId;

	return $result;
}