From 2d382bf870a8d5144b3a6e49469bda4bdacca391 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 23 Feb 2021 08:46:43 +0100 Subject: [PATCH] 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. --- .../OPNsense/Core/Api/FirmwareController.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php index ae1014186..a9870b3a0 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Core/Api/FirmwareController.php @@ -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; }