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

	if (!isset($arParams['MESSAGE_ID']))
	{
		throw new BitrixRestRestException("Message ID can't be empty", "MESSAGE_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
	}

	if (!isset($arParams['DIALOG_ID']) || !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);
	}

	if (!isset($arParams['RATING']))
	{
		$arParams['RATING'] = 'like';
	}

	$arParams['RATING'] = $arParams['RATING'] == 'dislike' ? 'dislike': 'like';

	if (!CIMMessenger::LinesSessionVote($arParams['DIALOG_ID'], $arParams['MESSAGE_ID'], $arParams['RATING']))
	{
		throw new BitrixRestRestException("Action completed without changes", "WITHOUT_CHANGES", CRestServer::STATUS_WRONG_REQUEST);
	}

	return true;
}