- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/lib/transfer/transferor.php
- Класс: BitrixVoximplantTransferTransferor
- Вызов: Transferor::completePhoneTransfer
static function completePhoneTransfer($firstCallId, $secondCallId, $initiatorUserId)
{
$firstCall = Call::load($firstCallId);
$secondCall = Call::load($secondCallId);
if (!$firstCall || !$secondCall)
{
return;
}
// in SIP protocol, the transferor and the transferee are not determined and the order of the calls depends on the phone model.
if($firstCall->getId() > $secondCall->getId())
{
// swap first and second call
$temp = $secondCall;
$secondCall = $firstCall;
$firstCall = $temp;
}
$firstCall->removeUsers([$initiatorUserId]);
$secondCall->removeUsers([$initiatorUserId]);
if($secondCall->isInternalCall())
{
$toUserId = $secondCall->getPortalUserId();
CVoxImplantHistory::TransferMessage($initiatorUserId, $toUserId, $firstCall->getCallerId());
if(!$firstCall->isInternalCall())
{
static::updateCrmData($firstCall, $secondCall, $toUserId);
}
}
else
{
// trying to guess second user by his mobile number
if($toUserId = CVoxImplantUser::GetByPhone($secondCall->getCallerId()))
{
CVoxImplantHistory::TransferMessage($initiatorUserId, $toUserId, $firstCall->getCallerId(), $secondCall->getCallerId());
if(!$firstCall->isInternalCall())
{
static::updateCrmData($firstCall, $secondCall, $toUserId);
}
}
else
{
CVoxImplantHistory::TransferMessagePSTN($initiatorUserId, $firstCall->getCallerId(), $secondCall->getCallerId());
}
}
}