diff options
author | Anna Larch <anna@nextcloud.com> | 2023-08-17 10:19:10 +0200 |
---|---|---|
committer | Daniel <mail@danielkesselberg.de> | 2023-08-26 17:21:50 +0200 |
commit | 7f11ee8c4af3305ad2ecb90b1f400ee79b74c51c (patch) | |
tree | 05df07ea22b353b2490c6a6fb9118044b69e8b9d /apps/settings | |
parent | efeb517eddc7f29857a5d633b5a00655c74f2465 (diff) | |
download | nextcloud-server-7f11ee8c4af3305ad2ecb90b1f400ee79b74c51c.tar.gz nextcloud-server-7f11ee8c4af3305ad2ecb90b1f400ee79b74c51c.zip |
fix(CardDAV): only run upgrade sync if 1000 users or less
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/settings')
5 files changed, 54 insertions, 0 deletions
diff --git a/apps/settings/composer/composer/autoload_classmap.php b/apps/settings/composer/composer/autoload_classmap.php index a2d62b53017..674b92b7cac 100644 --- a/apps/settings/composer/composer/autoload_classmap.php +++ b/apps/settings/composer/composer/autoload_classmap.php @@ -75,6 +75,7 @@ return array( 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => $baseDir . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids' => $baseDir . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php', + 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => $baseDir . '/../lib/SetupChecks/SupportedDatabase.php', diff --git a/apps/settings/composer/composer/autoload_static.php b/apps/settings/composer/composer/autoload_static.php index c76e3d84ae3..d78aa56c606 100644 --- a/apps/settings/composer/composer/autoload_static.php +++ b/apps/settings/composer/composer/autoload_static.php @@ -90,6 +90,7 @@ class ComposerStaticInitSettings 'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php', 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids' => __DIR__ . '/..' . '/../lib/SetupChecks/LdapInvalidUuids.php', 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php', + 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php', 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php', 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php', 'OCA\\Settings\\SetupChecks\\SupportedDatabase' => __DIR__ . '/..' . '/../lib/SetupChecks/SupportedDatabase.php', diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 80be57268b0..295f791babb 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -63,6 +63,7 @@ use OC\Lock\NoopLockingProvider; use OC\Lock\DBLockingProvider; use OC\MemoryInfo; use OCA\Settings\SetupChecks\CheckUserCertificates; +use OCA\Settings\SetupChecks\NeedsSystemAddressBookSync; use OCA\Settings\SetupChecks\LdapInvalidUuids; use OCA\Settings\SetupChecks\LegacySSEKeyFormat; use OCA\Settings\SetupChecks\PhpDefaultCharset; @@ -911,6 +912,7 @@ Raw output $checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator); $supportedDatabases = new SupportedDatabase($this->l10n, $this->connection); $ldapInvalidUuids = new LdapInvalidUuids($this->appManager, $this->l10n, $this->serverContainer); + $needsSystemAddressBookSync = new NeedsSystemAddressBookSync($this->config, $this->l10n); return new DataResponse( [ @@ -966,6 +968,7 @@ Raw output SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()], 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(), LdapInvalidUuids::class => ['pass' => $ldapInvalidUuids->run(), 'description' => $ldapInvalidUuids->description(), 'severity' => $ldapInvalidUuids->severity()], + 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 new file mode 100644 index 00000000000..4c7c182211f --- /dev/null +++ b/apps/settings/lib/SetupChecks/NeedsSystemAddressBookSync.php @@ -0,0 +1,46 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2023 Anna Larch <anna.larch@gmx.net> + * + * @author Anna Larch <anna.larch@gmx.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Settings\SetupChecks; + +use OCP\IConfig; +use OCP\IL10N; + +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 occured. Please run it manually by calling occ dav:sync-system-addressbook.'); + } + + public function severity(): string { + return 'warning'; + } + + public function run(): bool { + return $this->config->getAppValue('dav', 'needs_system_address_book_sync', 'no') === 'no'; + } +} diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index d4af6bd603c..21d7f10723a 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -92,6 +92,7 @@ class CheckSetupControllerTest extends TestCase { private $dispatcher; /** @var Connection|\PHPUnit\Framework\MockObject\MockObject */ private $db; + private IThrottler $throttler; /** @var ILockingProvider|\PHPUnit\Framework\MockObject\MockObject */ private $lockingProvider; /** @var IDateTimeFormatter|\PHPUnit\Framework\MockObject\MockObject */ @@ -435,6 +436,7 @@ class CheckSetupControllerTest extends TestCase { ->willReturnMap([ ['files_external', 'user_certificate_scan', '', '["a", "b"]'], ['core', 'cronErrors', '', ''], + ['dav', 'needs_system_address_book_sync', 'no', 'no'], ]); $this->config->expects($this->any()) ->method('getSystemValue') @@ -662,6 +664,7 @@ class CheckSetupControllerTest extends TestCase { 'isFairUseOfFreePushService' => false, 'temporaryDirectoryWritable' => false, \OCA\Settings\SetupChecks\LdapInvalidUuids::class => ['pass' => true, 'description' => 'Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.', 'severity' => 'warning'], + \OCA\Settings\SetupChecks\NeedsSystemAddressBookSync::class => ['pass' => true, 'description' => 'The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occured. Please run it manually by calling occ dav:sync-system-addressbook.', 'severity' => 'warning'], 'isBruteforceThrottled' => false, 'bruteforceRemoteAddress' => '', ] |