1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PushService.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Message\Param;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Message;
7use Bitrix\Im\V2\Message\Params;
8use CPullWatch;
9
11{
12 protected function isPullEnable(): bool
13 {
14 return \Bitrix\Main\Loader::includeModule('pull');
15 }
16
17
18 public function sendPull(Message $message, ?array $extraParams = null): void
19 {
20 if (!$this->isPullEnable())
21 {
22 return;
23 }
24
25 $chat = $message->getChat();
26 $params = $message->getEnrichedParams();
27
28 $pullParams = $this->getPullFormatParams($message);
29 $users = $chat->getRelations()->getUserIds();
30
31 if ($chat->getType() === IM_MESSAGE_PRIVATE)
32 {
33 $pullParams['params']['toUserId'] = $chat->getCompanion($message->getAuthorId())->getId();
34 $pullParams['params']['fromUserId'] = $message->getAuthorId();
35 }
36 else
37 {
38 $pullParams['params']['senderId'] = $message->getAuthorId();
39
40 if ($chat->getEntityType() === 'LINES')
41 {
42 $users = $this->getRecipients($chat);
43 }
44 }
45
46 $messageParams = $params->toPullFormat($extraParams);
47 $pullParams['params']['params'] = $messageParams;
48
49 if ($chat->getType() === Chat::IM_TYPE_COMMENT)
50 {
51 CPullWatch::AddToStack('IM_PUBLIC_COMMENT_' . $chat->getParentChatId(), $pullParams);
52 }
53 else
54 {
55 \Bitrix\Pull\Event::add($users, $pullParams);
56 }
57
58 if ($chat->needToSendPublicPull())
59 {
60 CPullWatch::AddToStack('IM_PUBLIC_' . $chat->getId(), $pullParams);
61 }
62 if ($chat->getType() === Chat::IM_TYPE_OPEN_CHANNEL && $message->getId() === $chat->getLastMessageId())
63 {
65 }
66 }
67
69 {
70 return [
71 'module_id' => 'im',
72 'command' => 'messageParamsUpdate',
73 'params' => [
74 'id' => $message->getId(),
75 'type' => $message->getChat()->getType() === IM_MESSAGE_PRIVATE ? 'private': 'chat',
76 'chatId' => $message->getChat()->getId(),
77 ],
79 ];
80 }
81
82 protected function getRecipients(Chat $chat): array
83 {
84 $users = $chat->getRelations()->getUserIds();
85
86 foreach ($chat->getRelations()->getUsers() as $user)
87 {
88 if ($user->getExternalAuthId() === 'imconnector')
89 {
90 unset($users[$user->getId()]);
91 }
92 }
93
94 return $users;
95 }
96}
static getUsers($chatId, $options=[])
Определения chat.php:736
static getPullExtra()
Определения common.php:127
static sendSharedPull(array $pull)
Определения OpenChannelChat.php:124
getPullFormatParams(Message $message)
Определения PushService.php:68
sendPull(Message $message, ?array $extraParams=null)
Определения PushService.php:18
getRecipients(Chat $chat)
Определения PushService.php:82
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
Определения event.php:22
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
const IM_MESSAGE_PRIVATE
Определения include.php:22
Определения Uuid.php:3
$user
Определения mysql_to_pgsql.php:33
$message
Определения payment.php:8
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799