• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Controller/Import/Message.php
  • Класс: BitrixImV2ControllerImportMessage
  • Вызов: Message::addAction
public function addAction(int $chatId, array $messages, CurrentUser $user): ?array
{
	if (count($messages) > 2000)
	{
		$this->addError(new MessageError(MessageError::TOO_MANY_MESSAGES));

		return null;
	}

	$chat = Chat::getById($chatId, ['CHECK_ACCESS' => 'N']);
	if (!$chat)
	{
		$this->addError(new ChatError(ChatError::NOT_FOUND));

		return null;
	}

	$importService = new ImportService($chat, (int)$user->getId());

	if (!$importService->hasAccess())
	{
		$this->addError(new ImportError(ImportError::ACCESS_ERROR));

		return null;
	}

	$addResult = $importService->addMessages($messages);

	if (!$addResult->isSuccess())
	{
		$this->addErrors($addResult->getErrors());

		return null;
	}

	return $this->convertKeysToCamelCase($addResult->getResult());
}