Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
ReplyService.php
1<?php
2
4
6use Bitrix\Im\V2\Common\ContextCustomer;
9
11{
12 use ContextCustomer;
13
19 public function createMessage(Message $replyingMessage, string $comment): Result
20 {
21 $result = new Result();
22 if (!$replyingMessage->getChat()->hasAccess($this->getContext()->getUserId()))
23 {
24 return $result->addError(new Chat\ChatError(Chat\ChatError::ACCESS_DENIED));
25 }
26
27 $messageId = \CIMMessenger::Add([
28 "MESSAGE_TYPE" => $replyingMessage->getChat()->getType(),
29 "MESSAGE" => $comment,
30 "PARAMS" => [
31 "REPLY_ID" => $replyingMessage->getMessageId(),
32 ],
33 "TO_CHAT_ID" => $replyingMessage->getChat()->getChatId(),
34 "FROM_USER_ID" => $this->getContext()->getUserId(),
35 ]);
36
37 if (!$messageId)
38 {
39 return $result->addError(new Message\MessageError(Message\MessageError::SENDING_FAILED));
40 }
41
42 return $result->setResult(new Message($messageId));
43 }
44
45}
createMessage(Message $replyingMessage, string $comment)