Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
PushService.php
1<?php
2
4
8
10{
11 public function isPullEnable(): bool
12 {
13 static $enable;
14 if ($enable === null)
15 {
16 $enable = \Bitrix\Main\Loader::includeModule('pull');
17 }
18 return $enable;
19 }
20
21 public function sendInformPushPrivateChat(PrivateChat $chat, Message $message): void
22 {
23 if (!$this->isPullEnable())
24 {
25 return;
26 }
27
28 $fromUserId = $message->getAuthorId();
29 $toUserId = $chat->getCompanion()->getId();
30
31 $pushFormat = new PushFormat();
32
33 $pullMessage = [
34 'module_id' => 'im',
35 'command' => 'informMessage',
36 'params' => $pushFormat->formatPrivateMessage($message, $chat),
37 'extra' => \Bitrix\Im\Common::getPullExtra(),
38 ];
39
40 $pullMessageTo = $pullMessage;
41 $pullMessageTo['params']['dialogId'] = $fromUserId;
42
43 if ($fromUserId != $toUserId)
44 {
45 \Bitrix\Pull\Event::add($toUserId, $pullMessageTo);
46 }
47 }
48}
getCompanion(?int $userId=null)
sendInformPushPrivateChat(PrivateChat $chat, Message $message)