diff options
Diffstat (limited to 'lib/AppInfo/Application.php')
-rw-r--r-- | lib/AppInfo/Application.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index d20ff7f1..18996bac 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -31,15 +31,36 @@ declare(strict_types=1); namespace OCA\Social\AppInfo; +use OC\DB\SchemaWrapper; +use OCA\Social\Notification\Notifier; +use OCA\Social\Service\ConfigService; +use OCA\Social\Service\UpdateService; use OCP\AppFramework\App; +use OCP\AppFramework\IAppContainer; +use OCP\AppFramework\QueryException; +/** + * Class Application + * + * @package OCA\Social\AppInfo + */ class Application extends App { const APP_NAME = 'social'; + /** @var ConfigService */ + private $configService; + + /** @var UpdateService */ + private $updateService; + + /** @var IAppContainer */ + private $container; + + /** * Application constructor. * @@ -47,6 +68,41 @@ class Application extends App { */ public function __construct(array $params = []) { parent::__construct(self::APP_NAME, $params); + + $this->container = $this->getContainer(); + + $manager = $this->container->getServer() + ->getNotificationManager(); + $manager->registerNotifierService(Notifier::class); + } + + + /** + * + */ + public function checkUpgradeStatus() { + $upgradeChecked = $this->container->getServer() + ->getConfig() + ->getAppValue(Application::APP_NAME, 'update_checked', ''); + + if ($upgradeChecked === '0.3') { + return; + } + + try { + $this->configService = $this->container->query(ConfigService::class); + $this->updateService = $this->container->query(UpdateService::class); + } catch (QueryException $e) { + return; + } + + $server = $this->container->getServer(); + $schema = new SchemaWrapper($server->getDatabaseConnection()); + if ($schema->hasTable('social_a2_stream')) { + $this->updateService->checkUpdateStatus(); + } + + $this->configService->setAppValue('update_checked', '0.3'); } } |