Fix #50 upgrade the code to fit with the new object format

Fix a fatal error in the view
This commit is contained in:
Timothée Jaussoin 2022-10-25 17:42:04 +02:00
parent 501f394bbc
commit 3da2a8fdd6
6 changed files with 16 additions and 15 deletions

View file

@ -26,9 +26,9 @@ class Device extends Model
{
public function fromContact(\stdClass $contact)
{
$this->uuid = \substr($contact->line_value_copy, 2, -2);
$this->expires_at = Carbon::createFromTimestamp($contact->expires_at);
$this->update_time = Carbon::createFromTimestamp($contact->update_time);
$this->user_agent = $contact->user_agent;
$this->uuid = \substr($contact->{'unique-id'}, 2, -2);
$this->expires_at = Carbon::createFromTimestamp($contact->{'expires-at'});
$this->update_time = Carbon::createFromTimestamp($contact->{'update-time'});
$this->user_agent = $contact->{'user-agent'};
}
}

View file

@ -27,8 +27,8 @@ class FlexisipConnector
public function __construct()
{
$pid = file_get_contents(config('app.flexisip_proxy_pid'));
$this->socket = streamsocket_client('unix:///tmp/flexisip-proxy-'.$pid, $errno, $errstr);
$pid = \file_get_contents(config('app.flexisip_proxy_pid'));
$this->socket = \stream_socket_client('unix:///tmp/flexisip-proxy-'.$pid, $errno, $errstr);
}
public function __destruct()
@ -43,7 +43,7 @@ class FlexisipConnector
]);
$devices = collect();
if (isset($content->contacts)) {
if ($content && isset($content->contacts)) {
foreach ($content->contacts as $contact) {
$device = new Device;
$device->fromContact($contact);
@ -62,9 +62,10 @@ class FlexisipConnector
]);
}
private function request(string $command, array $parameters)
private function request(string $command, array $parameters): ?\stdClass
{
fwrite($this->socket, $command.' '.\implode(' ', $parameters));
return json_decode(fread($this->socket, 8192));
}
}

10
flexiapi/composer.lock generated
View file

@ -1466,16 +1466,16 @@
},
{
"name": "laravel/framework",
"version": "v8.83.25",
"version": "v8.83.26",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "b77b908a9426efa41d6286a2ef4c3adbf5398ca1"
"reference": "7411d9fa71c1b0fd73a33e225f14512b74e6c81e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/b77b908a9426efa41d6286a2ef4c3adbf5398ca1",
"reference": "b77b908a9426efa41d6286a2ef4c3adbf5398ca1",
"url": "https://api.github.com/repos/laravel/framework/zipball/7411d9fa71c1b0fd73a33e225f14512b74e6c81e",
"reference": "7411d9fa71c1b0fd73a33e225f14512b74e6c81e",
"shasum": ""
},
"require": {
@ -1635,7 +1635,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2022-09-30T13:00:40+00:00"
"time": "2022-11-01T14:48:50+00:00"
},
{
"name": "laravel/serializable-closure",

Binary file not shown.

View file

@ -18,7 +18,7 @@
@foreach ($devices as $device)
<tr>
<td>{{ $device->user_agent }}</td>
<td>{{ $account->expires_at }}</td>
<td>{{ $device->expires_at }}</td>
<td>
<a type="button"
class="btn btn-danger"

View file

@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
%define build_number 161
%define build_number 162
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager