Update callback to check valid call return

This commit is contained in:
osaajani 2021-03-26 17:31:09 +01:00
parent c63f3bebba
commit 86c6d65fe4
2 changed files with 18 additions and 2 deletions

View File

@ -13,7 +13,8 @@
"twilio/sdk": "^6.1",
"symfony/yaml": "^5.0",
"phpmailer/phpmailer": "^6.1",
"ralouphie/mimey": "^2.1"
"ralouphie/mimey": "^2.1",
"kreait/firebase-php": "^5.14"
},
"require-dev": {
}

View File

@ -258,7 +258,7 @@ use Monolog\Logger;
*/
public function inbound_call(int $id_phone)
{
$this->logger->info('Callback reception call with phone : ' . $id_phone);
$this->logger->info('Callback inbound_call call with phone : ' . $id_phone);
$phone = $this->internal_phone->get_for_user($this->user['id'], $id_phone);
if (!$phone)
@ -291,6 +291,14 @@ use Monolog\Logger;
}
$call = $response['call'];
if (empty($call)  || empty($call['uid']) || empty($call['start']) || empty($call['origin']))
{
$this->logger->error('Callback inbound_call failed : missing required param in call return');
return false;
}
$result = $this->internal_call->create($this->user['id'], $id_phone, $call['uid'], \models\Call::DIRECTION_INBOUND, $call['start'], $call['end'] ?? null, $call['origin']);
if (!$result)
@ -349,6 +357,13 @@ use Monolog\Logger;
}
$call = $response['call'];
if (empty($call)  || empty($call['uid']) || empty($call['end']))
{
$this->logger->error('Callback end call failed : missing required param in call return');
return false;
}
$result = $this->internal_call->end($this->user['id'], $id_phone, $call['uid'], $call['end']);
if (!$result)