mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 14:36:52 +00:00
add an AIO outdated notification
Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
parent
bdcd4fc240
commit
de137f70ae
5 changed files with 92 additions and 2 deletions
|
|
@ -540,7 +540,7 @@ class DockerActionManager
|
|||
return true;
|
||||
}
|
||||
|
||||
public function sendNotification(Container $container, string $subject, string $message) : void
|
||||
public function sendNotification(Container $container, string $subject, string $message, string $file = '/notify.sh') : void
|
||||
{
|
||||
if ($this->GetContainerStartingState($container) instanceof RunningState) {
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ class DockerActionManager
|
|||
'Tty' => true,
|
||||
'Cmd' => [
|
||||
'bash',
|
||||
'/notify.sh',
|
||||
$file,
|
||||
$subject,
|
||||
$message
|
||||
],
|
||||
|
|
@ -739,4 +739,36 @@ class DockerActionManager
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function GetCreatedTimeOfNextcloudImage() : ?string {
|
||||
$imageName = 'nextcloud/aio-nextcloud' . ':' . $this->GetCurrentChannel();
|
||||
try {
|
||||
$imageUrl = $this->BuildApiUrl(sprintf('images/%s/json', $imageName));
|
||||
$imageOutput = json_decode($this->guzzleClient->get($imageUrl)->getBody()->getContents(), true);
|
||||
|
||||
if (!isset($imageOutput['Created'])) {
|
||||
error_log('Created is not set of image ' . $imageName);
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_replace('T', ' ', $imageOutput['Created']);
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function isNextcloudImageOutdated() : bool {
|
||||
$createdTime = $this->GetCreatedTimeOfNextcloudImage();
|
||||
|
||||
if ($createdTime === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the image is older than 90 days, it is outdated.
|
||||
if ((time() - (60 * 60 * 24 * 90)) > strtotime($createdTime)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue