diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-10-02 13:59:09 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-10-19 11:44:00 +0200 |
commit | 8bfa0935b43fe99c34732b9632905c86488238c7 (patch) | |
tree | b4e550206773f86d0d3da4eb034df02444fef8a7 | |
parent | 67e7a2635fad24113e9c86b25007c5648aa893d5 (diff) | |
download | nextcloud-server-8bfa0935b43fe99c34732b9632905c86488238c7.tar.gz nextcloud-server-8bfa0935b43fe99c34732b9632905c86488238c7.zip |
Migrate NeedsSystemAddressBookSync to new ISetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | apps/dav/lib/AppInfo/Application.php | 12 | ||||
-rw-r--r-- | apps/settings/lib/Controller/CheckSetupController.php | 4 | ||||
-rw-r--r-- | apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php | 29 |
3 files changed, 27 insertions, 18 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 9b185963dcc..22545b6c7e6 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -91,6 +91,7 @@ use OCA\DAV\Search\EventsSearchProvider; use OCA\DAV\Search\TasksSearchProvider; use OCA\DAV\UserMigration\CalendarMigrator; use OCA\DAV\UserMigration\ContactsMigrator; +use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -101,7 +102,6 @@ use OCP\Config\BeforePreferenceDeletedEvent; use OCP\Config\BeforePreferenceSetEvent; use OCP\Contacts\IManager as IContactsManager; use OCP\Files\AppData\IAppDataFactory; -use OCP\IServerContainer; use OCP\IUser; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; @@ -124,12 +124,12 @@ class Application extends App implements IBootstrap { $c->get(LoggerInterface::class) ); }); - $context->registerService(AppCalendarPlugin::class, function(ContainerInterface $c) { + $context->registerService(AppCalendarPlugin::class, function (ContainerInterface $c) { return new AppCalendarPlugin( - $c->get(ICalendarManager::class), - $c->get(LoggerInterface::class) + $c->get(ICalendarManager::class), + $c->get(LoggerInterface::class) ); - }); + }); /* * Register capabilities @@ -201,6 +201,8 @@ class Application extends App implements IBootstrap { $context->registerUserMigrator(CalendarMigrator::class); $context->registerUserMigrator(ContactsMigrator::class); + + $context->registerSetupCheck(NeedsSystemAddressBookSync::class); } public function boot(IBootContext $context): void { diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 564f39e411a..4977d8d17f2 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -61,7 +61,6 @@ use OC\IntegrityCheck\Checker; use OC\Lock\NoopLockingProvider; use OC\Lock\DBLockingProvider; use OC\MemoryInfo; -use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI; @@ -911,8 +910,6 @@ Raw output * @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\Overview) */ public function check() { - $needsSystemAddressBookSync = new NeedsSystemAddressBookSync($this->config, $this->l10n); - return new DataResponse( [ 'isGetenvServerWorking' => !empty(getenv('PATH')), @@ -961,7 +958,6 @@ Raw output 'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(), 'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '', 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(), - NeedsSystemAddressBookSync::class => ['pass' => $needsSystemAddressBookSync->run(), 'description' => $needsSystemAddressBookSync->description(), 'severity' => $needsSystemAddressBookSync->severity()], ] ); } diff --git a/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php b/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php index 3172abe70f7..a28d6093539 100644 --- a/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php +++ b/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php @@ -6,6 +6,7 @@ declare(strict_types=1); * @copyright Copyright (c) 2023 Anna Larch <anna.larch@gmx.net> * * @author Anna Larch <anna.larch@gmx.net> + * @author Côme Chilliet <come.chilliet@nextcloud.com> * * @license GNU AGPL version 3 or any later version * @@ -28,19 +29,29 @@ namespace OCA\Settings\SetupChecks; use OCP\IConfig; use OCP\IL10N; +use OCP\SetupCheck\ISetupCheck; +use OCP\SetupCheck\SetupResult; + +class NeedsSystemAddressBookSync implements ISetupCheck { + public function __construct( + private IConfig $config, + private IL10N $l10n, + ) { + } -class NeedsSystemAddressBookSync { - public function __construct(private IConfig $config, private IL10N $l10n) {} - - public function description(): string { - return $this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling "occ dav:sync-system-addressbook".'); + public function getName(): string { + return $this->l10n->t('Checking for DAV system address book'); } - public function severity(): string { - return 'warning'; + public function getCategory(): string { + return 'dav'; } - public function run(): bool { - return $this->config->getAppValue('dav', 'needs_system_address_book_sync', 'no') === 'no'; + public function run(): SetupResult { + if ($this->config->getAppValue('dav', 'needs_system_address_book_sync', 'no') === 'no') { + return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('The address book sync has already run')); + } else { + return new SetupResult(SetupResult::WARNING, $this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling occ dav:sync-system-addressbook.')); + } } } |