• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
  • Класс: CIMRestService
  • Вызов: CIMRestService::chatFavoriteDelete
static function chatFavoriteDelete($arParams, $n, CRestServer $server)
{
	$arParams = array_change_key_case($arParams, CASE_UPPER);
	if (!isset($arParams['MESSAGE_ID']) || (int)$arParams['MESSAGE_ID'] <= 0)
	{
		throw new BitrixRestRestException('MESSAGE_ID can`t be empty', 'MESSAGE_ID_EMPTY', CRestServer::STATUS_WRONG_REQUEST);
	}

	$messageId = (int)$arParams['MESSAGE_ID'];

	$message = new BitrixImV2Message($messageId);

	if ($message->getMessageId() === null)
	{
		throw new BitrixRestRestException('Message not found', BitrixImV2MessageMessageError::MESSAGE_NOT_FOUND, CRestServer::STATUS_WRONG_REQUEST);
	}

	$unmarkResult = $message->unmarkAsFavorite();
	if (!$unmarkResult->isSuccess())
	{
		$error = $unmarkResult->getErrors()[0];
		if (isset($error))
		{
			throw new BitrixRestRestException($error->getMessage(), $error->getCode(), CRestServer::STATUS_WRONG_REQUEST);
		}
	}

	return $unmarkResult->isSuccess();
}