29 $resultSend = $this->sendPull();
30 if (!$resultSend->isSuccess())
35 $resultSendLegacy = $this->sendLegacyPull();
36 if (!$resultSendLegacy->isSuccess())
38 return $resultSendLegacy;
41 $this->sendLegacyEvent();
61 private function sendPull():
Result
64 ->setContext($this->context)
65 ->setCustomUserName($this->customUserName)
71 private function sendLegacyPull():
Result
73 if ($this->type !== Type::Writing)
78 $pull = (
new StartWriting($this->chat))
79 ->setContext($this->context)
80 ->setCustomUserName($this->customUserName)
86 private function sendLegacyEvent(): void
88 if ($this->type !== Type::Writing)
94 'DIALOG_ID' => $this->chat->getDialogId(),
95 'CHAT' => $this->getChatArray(),
96 'RELATION' => $this->getRelationsArray(),
97 'USER_ID' => $this->getContext()->getUserId(),
98 'USER_NAME' => $this->customUserName ?? $this->getContext()->getUser()->getName(),
109 private function getRelationsArray():
array
111 $relationsArray = [];
112 if ($this->chat instanceof Chat\PrivateChat)
117 foreach ($this->chat->getRelations() as $relation)
119 $relationArray = $relation->toArray();
120 $relationArray[
'EXTERNAL_AUTH_ID'] = $relation->getUser()->getExternalAuthId();
121 $relationsArray[] = static::convertBoolToChar($relationArray);
124 return $relationsArray;
127 private function getChatArray():
array
129 if ($this->chat instanceof Chat\PrivateChat)
134 return static::convertBoolToChar($this->chat->toArray());
144 private static function convertBoolToChar(
array $array):
array
146 foreach ($array as $field => $value)
150 $array[$field] =
$value ?
'Y' :
'N';