1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PushService.php
См. документацию.
1<?php
2
4
8
10{
11 private const ADD_REACTION_EVENT = 'addReaction';
12 private const DELETE_REACTION_EVENT = 'deleteReaction';
13
14 public function add(ReactionItem $reaction): void
15 {
16 $this->send(self::ADD_REACTION_EVENT, $reaction);
17 }
18
19 public function delete(ReactionItem $reaction): void
20 {
21 $this->send(self::DELETE_REACTION_EVENT, $reaction);
22 }
23
24 private function send(string $eventName, ReactionItem $reaction): void
25 {
26 $converter = new Converter(Converter::KEYS | Converter::VALUES | Converter::TO_LOWER | Converter::LC_FIRST);
27 $messageId = $reaction->getMessageId();
28 $reactionMessage = (new ReactionMessages([$messageId], false))->getReactionMessage($messageId);
29 $params = [
30 'userId' => $reaction->getUserId(),
31 'reaction' => $converter->process($reaction->getReaction()),
32 'actualReactions' => (new RestAdapter($reactionMessage))->toRestFormat(),
33 'dialogId' => Chat::getInstance($reaction->getChatId())->getDialogId(),
34 ];
35 $chat = Chat::getInstance($reaction->getChatId());
36
37 if ($chat instanceof Chat\PrivateChat)
38 {
39 $this->sendToPrivateChat($params, $eventName, $reaction);
40
41 return;
42 }
43
44 $pull = [
45 'module_id' => 'im',
46 'command' => $eventName,
47 'params' => $params,
49 ];
50
51 if ($chat->getType() === Chat::IM_TYPE_COMMENT)
52 {
53 \CPullWatch::AddToStack('IM_PUBLIC_COMMENT_'.$chat->getParentChatId(), $pull);
54 }
55 else
56 {
57 \Bitrix\Pull\Event::add($this->getRecipient($reaction), $pull);
58 }
59
60 if ($chat->needToSendPublicPull())
61 {
62 \CPullWatch::AddToStack('IM_PUBLIC_'.$chat->getChatId(), $pull);
63 }
64 }
65
66 private function sendToPrivateChat(array $params, string $eventName, ReactionItem $reaction): void
67 {
69 $chat = Chat::getInstance($reaction->getChatId());
70 foreach ($this->getRecipient($reaction) as $recipient)
71 {
72 $params['dialogId'] = $chat->getCompanion($recipient)->getId();
73 \Bitrix\Pull\Event::add($recipient, [
74 'module_id' => 'im',
75 'command' => $eventName,
76 'params' => $params,
77 'extra' => \Bitrix\Im\Common::getPullExtra()
78 ]);
79 }
80 }
81
82 private function getRecipient(ReactionItem $reaction): array
83 {
84 $userIds = [];
85 $relations = Chat::getInstance($reaction->getChatId())->getRelations();
86
87 foreach ($relations as $relation)
88 {
89 if ($relation->getStartId() <= $reaction->getMessageId())
90 {
91 $userIds[] = $relation->getUserId();
92 }
93 }
94
95 return $userIds;
96 }
97}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
static getPullExtra()
Определения common.php:127
add(ReactionItem $reaction)
Определения PushService.php:14
static getInstance()
Определения application.php:98
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
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799