firmware: changelogs are pulled from check scripts

Like with text output earlier the update feature is not used
from the GUI and brings little to the table.  Separate API
endpoint is better for these types of actions if the need should
ever arise.
This commit is contained in:
Franco Fichtner 2021-02-23 08:46:43 +01:00
parent b25727a11b
commit 2d382bf870

View File

@ -315,29 +315,28 @@ class FirmwareController extends ApiControllerBase
*/
public function changelogAction($version)
{
$this->sessionClose(); // long running action, close session
$backend = new Backend();
$response = array();
$response = ['status' => 'failure'];
if (!$this->request->isPost()) {
return $response;
}
$this->sessionClose(); // long running action, close session
$filter = new \Phalcon\Filter();
$filter->add('version', function ($value) {
return preg_replace('/[^0-9a-zA-Z\.]/', '', $value);
});
$version = $filter->sanitize($version, 'version');
if ($version == 'update') {
$backend->configdRun('firmware changelog fetch');
} else {
$html = trim($backend->configdRun(sprintf('firmware changelog html %s', $version)));
if (!empty($html)) {
$response['html'] = $html;
}
$backend = new Backend();
$html = trim($backend->configdRun(sprintf('firmware changelog html %s', $version)));
if (!empty($html)) {
$response['status'] = 'ok';
$response['html'] = $html;
}
return $response;
}