3namespace Bitrix\Im\Call;
5use Bitrix\Im\Call\Integration\Chat;
6use Bitrix\Main\ArgumentException;
8use Bitrix\Main\Localization\Loc;
19 public function sendInviteToUser(
int $senderId,
int $toUserId, $invitedUsers, $isLegacyMobile,
bool $video =
false,
bool $sendPush =
true)
21 $users = $this->call->getUsers();
23 $parentCall = $this->call->getParentId() ?
Call::loadWithId($this->call->getParentId()) :
null;
24 $skipPush = $parentCall ? $parentCall->getUsers() : [];
25 $skipPush = array_flip($skipPush);
27 $associatedEntity = $this->call->getAssociatedEntity();
28 $isBroadcast = ($associatedEntity instanceof
Chat) && $associatedEntity->isBroadcast();
31 'call' => $this->call->toArray(($senderId == $toUserId ? $toUserId : 0)),
33 'invitedUsers' => $invitedUsers,
34 'userData' => $this->call->getUserData(),
35 'senderId' => $senderId,
37 'isLegacyMobile' => $isLegacyMobile,
39 'logToken' => $this->call->getLogToken($toUserId),
41 $connectionData = $this->call->getConnectionData($toUserId);
42 if ($connectionData !==
null)
44 $config[
'connectionData'] = $connectionData;
48 if (!isset($skipPush[$toUserId]) && $sendPush && !$isBroadcast)
50 $push = $this->
getInvitePush($senderId, $toUserId, $isLegacyMobile, $video);
53 $this->
send(
'Call::incoming', $toUserId,
$config, $push);
56 public function sendInvite(
int $senderId,
array $toUserIds, $isLegacyMobile,
bool $video =
false,
bool $sendPush =
true)
58 $users = $this->call->getUsers();
60 $parentCall = $this->call->getParentId() ?
Call::loadWithId($this->call->getParentId()) :
null;
61 $skipPush = $parentCall ? $parentCall->getUsers() : [];
62 $skipPush = array_flip($skipPush);
64 $associatedEntity = $this->call->getAssociatedEntity();
65 $isBroadcast = ($associatedEntity instanceof
Chat) && $associatedEntity->isBroadcast();
67 foreach ($toUserIds as $toUserId)
71 'call' => $this->call->toArray((
count($toUserIds) == 1 ? $toUserId : 0)),
73 'invitedUsers' => $toUserIds,
74 'userData' => $this->call->getUserData(),
75 'senderId' => $senderId,
77 'isLegacyMobile' => $isLegacyMobile,
79 'logToken' => $this->call->getLogToken($toUserId),
81 $connectionData = $this->call->getConnectionData($toUserId);
82 if ($connectionData !==
null)
84 $config[
'connectionData'] = $connectionData;
86 if (!isset($skipPush[$toUserId]) && $sendPush && !$isBroadcast)
88 $push = $this->
getInvitePush($senderId, $toUserId, $isLegacyMobile, $video);
91 $this->
send(
'Call::incoming', $toUserId,
$config, $push);
97 $users = $this->call->getUsers();
98 $associatedEntity = $this->call->getAssociatedEntity();
99 $name = $associatedEntity ? $associatedEntity->getName($toUserId) : Loc::getMessage(
'IM_CALL_INVITE_NA');
103 if ($associatedEntity instanceof
Chat)
105 if ($associatedEntity->isPrivateChat())
108 $email = $userInstance->getEmail();
109 $phone = $userInstance->getPhone();
110 $phone = preg_replace(
"/[^0-9#*+,;]/",
"", $phone);
112 $avatar = $associatedEntity->getAvatar($toUserId);
115 $pushText = Loc::getMessage(
'IM_CALL_INVITE', [
'#USER_NAME#' =>
$name]);
116 $pushTag =
'IM_CALL_'.$this->call->getId();
118 'message' => $pushText,
121 'ACTION' =>
'IMINV_'.$this->call->getId().
"_".time().
"_".($video ?
'Y' :
'N'),
123 'type' =>
'internal',
125 'callerAvatar' => $avatar ??
'',
126 'call' => $this->call->toArray($toUserId),
129 'isLegacyMobile' => $isLegacyMobile,
130 'senderId' => $senderId,
132 'senderPhone' => $phone,
133 'logToken' => $this->call->getLogToken($toUserId),
137 'advanced_params' => [
139 'notificationsToCancel' => [$pushTag],
140 'androidHighPriority' =>
true,
141 'useVibration' =>
true,
145 'sound' =>
'call.aif',
146 'send_immediately' =>
'Y',
149 $connectionData = $this->call->getConnectionData($toUserId);
150 if ($connectionData !==
null)
152 $push[
'params'][
'PARAMS'][
'connectionData'] = $connectionData;
166 'call' => $this->call->toArray(),
167 'users' => $joinedUsers,
168 'userData' => $this->call->prepareUserData($joinedUsers),
169 'senderId' => $senderId,
173 return $this->
send(
'Call::usersJoined', $this->call->getUsers(),
$config);
179 'call' => $this->call->toArray(),
181 'userData' => $this->call->prepareUserData($users),
182 'senderId' => $senderId,
187 return $this->
send(
'Call::usersInvited', $toUserIds,
$config);
193 'call' => $this->call->toArray(),
194 'senderId' => $senderId,
197 $toUserIds = $this->call->getUsers();
199 return $this->
send(
'Call::associatedEntityReplaced', $toUserIds,
$config);
202 public function sendAnswer(
int $senderId, $callInstanceId, $isLegacyMobile)
205 'call' => $this->call->toArray(),
206 'senderId' => $senderId,
207 'callInstanceId' => $callInstanceId,
208 'isLegacyMobile' => $isLegacyMobile,
211 $toUserIds = array_diff($this->call->getUsers(), [$senderId]);
212 $this->
send(
'Call::answer', $toUserIds,
$config,
null, 3600);
215 'send_immediately' =>
'Y',
218 'advanced_params' => [
219 'id' =>
'IM_CALL_'.$this->call->getId().
'_ANSWER',
220 'notificationsToCancel' => [
'IM_CALL_'.$this->call->getId()],
223 'filterCallback' => [static::class,
'filterPushesForApple'],
227 $this->
send(
'Call::answer', $senderId,
$config, $push, 3600);
230 public function sendPing(
int $senderId, $requestId)
233 'requestId' => $requestId,
234 'callId' => $this->call->getId(),
235 'senderId' => $senderId
238 $toUserIds = $this->call->getUsers();
239 $toUserIds = array_filter($toUserIds,
function ($value) use ($senderId) {
240 return $value != $senderId;
242 return $this->
send(
'Call::ping', $toUserIds,
$config,
null, 0);
247 return $this->
send(
'Call::negotiationNeeded', $toUserId, [
248 'senderId' => $senderId,
249 'restart' => $restart
253 public function sendConnectionOffer(
int $senderId,
int $toUserId,
string $connectionId,
string $offerSdp,
string $userAgent)
255 return $this->
send(
'Call::connectionOffer', $toUserId, [
256 'senderId' => $senderId,
257 'connectionId' => $connectionId,
259 'userAgent' => $userAgent
263 public function sendConnectionAnswer(
int $senderId,
int $toUserId,
string $connectionId,
string $answerSdp,
string $userAgent)
265 return $this->
send(
'Call::connectionAnswer', $toUserId, [
266 'senderId' => $senderId,
267 'connectionId' => $connectionId,
269 'userAgent' => $userAgent
275 return $this->
send(
'Call::iceCandidate', $toUserId, [
276 'senderId' => $senderId,
277 'connectionId' => $connectionId,
278 'candidates' => $iceCandidates
285 'senderId' => $senderId,
286 'callInstanceId' => $callInstanceId,
291 'send_immediately' =>
'Y',
294 'advanced_params' => [
295 'id' =>
'IM_CALL_'.$this->call->getId().
'_FINISH',
296 'notificationsToCancel' => [
'IM_CALL_'.$this->call->getId()],
298 'filterCallback' => [static::class,
'filterPushesForApple'],
302 return $this->
send(
'Call::hangup', $toUserIds,
$config, $push, 3600);
308 'send_immediately' =>
'Y',
311 'advanced_params' => [
312 'id' =>
'IM_CALL_'.$this->call->getId().
'_FINISH',
313 'notificationsToCancel' => [
'IM_CALL_'.$this->call->getId()],
315 'filterCallback' => [static::class,
'filterPushesForApple'],
319 return $this->
send(
'Call::finish', $this->call->getUsers(), [], $push, 3600);
324 $toUserIds = array_diff($this->call->getUsers(), [$senderId]);
326 return $this->
send(
'Call::switchTrackRecordStatus', $toUserIds, [
327 'senderId' => $senderId,
328 'isTrackRecordOn' => $isTrackRecordOn,
329 'callUuid' => $this->call->getUuid(),
330 'errorCode' => $errorCode,
336 if (!Loader::includeModule(
'pull'))
353 if (!Loader::includeModule(
'pull'))
358 return \Bitrix\Pull\Channel::getPublicIds([
364 protected function send(
string $command, $users,
array $params = [], $push =
null, $ttl = 5)
366 if (!Loader::includeModule(
'pull'))
374 'ID' => $this->call->getId(),
375 'UUID' => $this->call->getUuid(),
376 'PROVIDER' => $this->call->getProvider(),
377 'SCHEME' => $this->call->getScheme(),
383 $params[
'callId'] = $this->call->getId();
388 'command' => $command,
sendSwitchTrackRecordStatus(int $senderId, bool $isTrackRecordOn, string $errorCode='')
sendHangup(int $senderId, array $toUserIds, ?string $callInstanceId, $code=200)
getPublicIds(array $userIds)
getInvitePush(int $senderId, int $toUserId, $isLegacyMobile, $video)
static filterPushesForApple($message, $deviceType, $deviceToken)
sendAnswer(int $senderId, $callInstanceId, $isLegacyMobile)
sendConnectionOffer(int $senderId, int $toUserId, string $connectionId, string $offerSdp, string $userAgent)
sendAssociatedEntityReplaced(int $senderId)
send(string $command, $users, array $params=[], $push=null, $ttl=5)
sendInviteToUser(int $senderId, int $toUserId, $invitedUsers, $isLegacyMobile, bool $video=false, bool $sendPush=true)
sendPing(int $senderId, $requestId)
sendUsersJoined(int $senderId, array $joinedUsers)
sendInvite(int $senderId, array $toUserIds, $isLegacyMobile, bool $video=false, bool $sendPush=true)
sendUsersInvited(int $senderId, array $toUserIds, array $users, bool $show)
sendConnectionAnswer(int $senderId, int $toUserId, string $connectionId, string $answerSdp, string $userAgent)
sendIceCandidates(int $senderId, int $toUserId, string $connectionId, array $iceCandidates)
sendNegotiationNeeded(int $senderId, int $toUserId, $restart)
static getInstance($userId=null)
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
htmlspecialcharsback($str)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']