- Модуль: messageservice
- Путь к файлу: ~/bitrix/modules/messageservice/lib/restservice.php
- Класс: BitrixMessageServiceRestService
- Вызов: RestService::updateMessageStatus
static function updateMessageStatus($params, $n, $server)
{
if(!$server->getClientId())
{
throw new AccessException("Application context required");
}
$params = array_change_key_case($params, CASE_UPPER);
static::validateSenderCode($params['CODE']);
if (empty($params['MESSAGE_ID']))
{
throw new RestException('Message not found!', self::ERROR_MESSAGE_NOT_FOUND);
}
$statusId = isset($params['STATUS']) ? SenderSmsRest::resolveStatus($params['STATUS']) : null;
if ($statusId === null || $statusId === MessageStatus::UNKNOWN)
{
throw new RestException('Message status incorrect!', self::ERROR_MESSAGE_STATUS_INCORRECT);
}
$message = Message::loadByExternalId(
'rest',
$params['MESSAGE_ID'],
$server->getClientId().'|'.$params['CODE']
);
if (!$message)
{
throw new RestException('Message not found!', self::ERROR_MESSAGE_NOT_FOUND);
}
if ($message->getAuthorId() !== static::getUserId())
{
static::checkAdminPermissions();
}
$message->updateStatus($statusId);
return true;
}