11 private const ADD_REACTION_EVENT =
'addReaction';
12 private const DELETE_REACTION_EVENT =
'deleteReaction';
16 $this->send(self::ADD_REACTION_EVENT, $reaction);
21 $this->send(self::DELETE_REACTION_EVENT, $reaction);
24 private function send(
string $eventName,
ReactionItem $reaction): void
26 $converter =
new Converter(Converter::KEYS | Converter::VALUES | Converter::TO_LOWER | Converter::LC_FIRST);
28 $reactionMessage = (
new ReactionMessages([$messageId],
false))->getReactionMessage($messageId);
31 'reaction' => $converter->process($reaction->
getReaction()),
32 'actualReactions' => (
new RestAdapter($reactionMessage))->toRestFormat(),
39 $this->sendToPrivateChat($params, $eventName, $reaction);
44 \Bitrix\Pull\Event::add($this->getRecipient($reaction), [
46 'command' => $eventName,
53 \CPullWatch::AddToStack(
'IM_PUBLIC_'.$chat->getChatId(), Array(
55 'command' => $eventName,
62 private function sendToPrivateChat(array $params,
string $eventName, ReactionItem $reaction): void
66 foreach ($this->getRecipient($reaction) as $recipient)
68 $params[
'dialogId'] = $chat->getCompanion($recipient)->getId();
69 \Bitrix\Pull\Event::add($recipient, [
71 'command' => $eventName,
78 private function getRecipient(ReactionItem $reaction): array
83 foreach ($relations as $relation)
85 if ($relation->getStartId() <= $reaction->getMessageId())
87 $userIds[] = $relation->getUserId();