Skip to content

Commit

Permalink
Merge pull request #434 from peschmae/master
Browse files Browse the repository at this point in the history
Add update info to serverinfo api call
  • Loading branch information
blizzz authored May 23, 2023
2 parents c57d58e + 057cb55 commit efe466a
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 efe466a

Please sign in to comment.