Skip to content

Commit

Permalink
Add update info to serverinfo api call
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Petermann <mathias.petermann@gmail.com>
  • Loading branch information
peschmae committed May 23, 2023
1 parent 1dea4ef commit 057cb55
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/SystemStatistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function getSystemStatistics(): array {
$memoryUsage = $this->os->getMemory();
return [
'version' => $this->config->getSystemValue('version'),
'update' => $this->getServerUpdateInfo(),
'theme' => $this->config->getSystemValue('theme', 'none'),
'enable_avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
'enable_previews' => $this->config->getSystemValue('enable_previews', true) ? 'yes' : 'no',
Expand All @@ -74,6 +75,28 @@ public function getSystemStatistics(): array {
];
}

/**
* Get info about server updates and last checked timestamp
*
* @return array information about core updates
*/
protected function getServerUpdateInfo(): array {
$updateInfo = [
'lastupdatedat' => (int) $this->config->getAppValue('core', 'lastupdatedat'),
'available' => false,
];

$lastUpdateResult = json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
if (is_array($lastUpdateResult)) {
$updateInfo['available'] = (count($lastUpdateResult) > 0);
if (array_key_exists('version', $lastUpdateResult)) {
$updateInfo['available_version'] = $lastUpdateResult['version'];
}
}

return $updateInfo;
}

/**
* Get some info about installed apps, including available updates.
*
Expand Down

0 comments on commit 057cb55

Please sign in to comment.