Skip to content

Commit

Permalink
feat(freepbx): Trigger phones configuration reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Stell0 committed Feb 14, 2025
1 parent f1337cd commit 23758b7
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions freepbx/var/www/html/freepbx/rest/modules/provisioning-v2.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,17 @@
return new CronHelper();
};

$app->post('/phones/reboot', function (Request $request, Response $response, $args) {
// DUMMY just return 200 since Cron is broken and will be probably removed
return $response->withStatus(200);
});

$app->get('/phones/reboot[/{mac}]', function (Request $request, Response $response, $args) {
// DUMMY just return 200 since Cron is broken and will be probably removed
return $response->withStatus(200);
});

$app->delete('/phones/reboot', function (Request $request, Response $response, $args) {
// DUMMY just return 200 since Cron is broken and will be probably removed
/* Send SIP notify to a phone to trigger configuration reload */
$app->post('/phones/reconfigure', function (Request $request, Response $response, $args) {
try {
$extension = $request->getParsedBody()['extension'];
$res = $astman->send_request('Command',array('Command'=>"pjsip send notify generic-reload endpoint $extension"));
if ($res['Response'] !== 'Success' || preg_match('/failed.$/m', $res['data']) || preg_match('/^Unable/m', $res['data'])) {
throw new Exception('Error reconfiguring extension '.$extension);
}
} catch (Exception $e) {
return $response->withStatus(500);
}
return $response->withStatus(200);
});

Expand Down

0 comments on commit 23758b7

Please sign in to comment.