• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/Send/SendingService.php
  • Класс: BitrixImV2MessageSendSendingService
  • Вызов: SendingService::checkDuplicateByUuid
public function checkDuplicateByUuid(Message $message): Result
{
	$result = new Result;

	if (
		$message->getUuid()
		&& !$message->isSystem()
		&& Uuid::validate($message->getUuid())
	)
	{
		$this->uuidService = new Uuid($message->getUuid());
		$uuidAddResult = $this->uuidService->add();
		// if it is false, then UUID already exists
		if (!$uuidAddResult)
		{
			$messageIdByUuid = $this->uuidService->getMessageId();

			// if we got message_id, then message already exists, and we don't need to add it, so return with ID.
			if (!is_null($messageIdByUuid))
			{
				return $result->setResult(['messageId' => $messageIdByUuid]);
			}

			// if there is no message_id and entry date is expired,
			// then update date_create and return false to delay next sending on the client.
			if (!$this->uuidService->updateIfExpired())
			{
				return $result->addError(new MessageError(MessageError::MESSAGE_DUPLICATED_BY_UUID));
			}
		}
	}

	return $result;
}