- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/Reply/ReplyService.php
- Класс: BitrixImV2MessageReplyReplyService
- Вызов: ReplyService::createMessage
public function createMessage(Message $replyingMessage, string $comment): Result
{
$result = new Result();
if (!$replyingMessage->getChat()->hasAccess($this->getContext()->getUserId()))
{
return $result->addError(new ChatChatError(ChatChatError::ACCESS_DENIED));
}
$messageId = CIMMessenger::Add([
"MESSAGE_TYPE" => $replyingMessage->getChat()->getType(),
"MESSAGE" => $comment,
"PARAMS" => [
"REPLY_ID" => $replyingMessage->getMessageId(),
],
"TO_CHAT_ID" => $replyingMessage->getChat()->getChatId(),
"FROM_USER_ID" => $this->getContext()->getUserId(),
]);
if (!$messageId)
{
return $result->addError(new MessageMessageError(MessageMessageError::SENDING_FAILED));
}
return $result->setResult(new Message($messageId));
}