Fixed the response when the result is an array

This commit is contained in:
FusionPBX 2025-03-29 14:48:45 -06:00 committed by GitHub
parent 091dca3ceb
commit f9bd89ef78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 6 deletions

View File

@ -402,23 +402,32 @@
//send the api command //send the api command
if (!empty($command) && $event_socket->is_connected()) { if (!empty($command) && $event_socket->is_connected()) {
$response_api[$registration['user']]['command'] = $event_socket->request('api ' . $command); $response = $event_socket->request('api ' . $command);
$response_api[$registration['user']]['log'] = $event_socket->request("log notice $command"); $response_api[$user]['command'] = $command;
$response_api[$user]['log'] = $response;
} }
} }
} }
//set message //set message
if (is_array($response_api)) { if (is_array($response_api)) {
$message = $response_message;
foreach ($response_api as $registration_user => $response) { foreach ($response_api as $registration_user => $response) {
if (trim($response['command']) != '-ERR no reply') { if (is_array($response['command'])) {
$message .= "<br>\n<strong>".$registration_user."</strong>: ".$response['command']; foreach($response['command'] as $command) {
$command = trim($command ?? '');
if ($command !== '-ERR no reply') {
$message .= "<br>\n<strong>".escape($registration_user)."</strong>: ".escape($response_message);
}
}
}
else {
if (!empty($response['command']) && $response['command'] !== '-ERR no reply') {
$message .= "<br>\n<strong>".escape($registration_user)."</strong>: ".escape($response_message);
}
} }
} }
message::add($message, 'positive', '7000'); message::add($message, 'positive', '7000');
} }
} }
else { else {
message::add($text['error-event-socket'], 'negative', 5000); message::add($text['error-event-socket'], 'negative', 5000);