- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/controller/call.php
- Класс: BitrixImControllerCall
- Вызов: Call::answerAction
public function answerAction($callId, $callInstanceId, $legacyMobile = "N")
{
$isLegacyMobile = $legacyMobile === "Y";
$currentUserId = $this->getCurrentUser()->getId();
$call = Registry::getCallWithId($callId);
if (!$call)
{
$this->addError(new Error(Loc::getMessage("IM_REST_CALL_ERROR_CALL_NOT_FOUND"), "call_not_found"));
return null;
}
if(!$this->checkCallAccess($call, $currentUserId))
return null;
$callUser = $call->getUser($currentUserId);
$lockName = static::getLockNameWithCallId($callId);
if (!Application::getConnection()->lock($lockName, static::LOCK_TTL))
{
$this->addError(new Error("Could not get exclusive lock", "could_not_lock"));
return null;
}
if ($callUser)
{
$callUser->update([
'STATE' => CallUser::STATE_READY,
'LAST_SEEN' => new DateTime(),
'FIRST_JOINED' => $callUser->getFirstJoined() ? $callUser->getFirstJoined() : new DateTime(),
'IS_MOBILE' => $isLegacyMobile ? 'Y' : 'N',
]);
}
Application::getConnection()->unlock($lockName);
$call->getSignaling()->sendAnswer($currentUserId, $callInstanceId, $isLegacyMobile);
}