Skip to content

Commit b39ccb4

Browse files
fixup! fix: automatically disable sab
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent b3bbcd6 commit b39ccb4

4 files changed

Lines changed: 27 additions & 12 deletions

File tree

apps/dav/appinfo/info.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<step>OCA\DAV\Migration\CalDAVRemoveEmptyValue</step>
4040
<step>OCA\DAV\Migration\BuildCalendarSearchIndex</step>
4141
<step>OCA\DAV\Migration\BuildSocialSearchIndex</step>
42+
<step>OCA\DAV\Migration\DisableSystemAddressBook</step>
4243
<step>OCA\DAV\Migration\RefreshWebcalJobRegistrar</step>
4344
<step>OCA\DAV\Migration\RegisterBuildReminderIndexBackgroundJob</step>
4445
<step>OCA\DAV\Migration\RegisterUpdateCalendarResourcesRoomBackgroundJob</step>

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
'OCA\\DAV\\Migration\\ChunkCleanup' => $baseDir . '/../lib/Migration/ChunkCleanup.php',
321321
'OCA\\DAV\\Migration\\CreateSystemAddressBookStep' => $baseDir . '/../lib/Migration/CreateSystemAddressBookStep.php',
322322
'OCA\\DAV\\Migration\\DeleteSchedulingObjects' => $baseDir . '/../lib/Migration/DeleteSchedulingObjects.php',
323+
'OCA\\DAV\\Migration\\DisableSystemAddressBook' => $baseDir . '/../lib/Migration/DisableSystemAddressBook.php',
323324
'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => $baseDir . '/../lib/Migration/FixBirthdayCalendarComponent.php',
324325
'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => $baseDir . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
325326
'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => $baseDir . '/../lib/Migration/RegenerateBirthdayCalendars.php',
@@ -356,7 +357,6 @@
356357
'OCA\\DAV\\Migration\\Version1029Date20231004091403' => $baseDir . '/../lib/Migration/Version1029Date20231004091403.php',
357358
'OCA\\DAV\\Migration\\Version1030Date20240205103243' => $baseDir . '/../lib/Migration/Version1030Date20240205103243.php',
358359
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => $baseDir . '/../lib/Migration/Version1031Date20240610134258.php',
359-
'OCA\\DAV\\Migration\\Version1032Date20250701000000' => $baseDir . '/../lib/Migration/Version1032Date20250701000000.php',
360360
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => $baseDir . '/../lib/Migration/Version1034Date20250813093701.php',
361361
'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php',
362362
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.php',

apps/dav/composer/composer/autoload_static.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ class ComposerStaticInitDAV
335335
'OCA\\DAV\\Migration\\ChunkCleanup' => __DIR__ . '/..' . '/../lib/Migration/ChunkCleanup.php',
336336
'OCA\\DAV\\Migration\\CreateSystemAddressBookStep' => __DIR__ . '/..' . '/../lib/Migration/CreateSystemAddressBookStep.php',
337337
'OCA\\DAV\\Migration\\DeleteSchedulingObjects' => __DIR__ . '/..' . '/../lib/Migration/DeleteSchedulingObjects.php',
338+
'OCA\\DAV\\Migration\\DisableSystemAddressBook' => __DIR__ . '/..' . '/../lib/Migration/DisableSystemAddressBook.php',
338339
'OCA\\DAV\\Migration\\FixBirthdayCalendarComponent' => __DIR__ . '/..' . '/../lib/Migration/FixBirthdayCalendarComponent.php',
339340
'OCA\\DAV\\Migration\\RefreshWebcalJobRegistrar' => __DIR__ . '/..' . '/../lib/Migration/RefreshWebcalJobRegistrar.php',
340341
'OCA\\DAV\\Migration\\RegenerateBirthdayCalendars' => __DIR__ . '/..' . '/../lib/Migration/RegenerateBirthdayCalendars.php',
@@ -371,7 +372,6 @@ class ComposerStaticInitDAV
371372
'OCA\\DAV\\Migration\\Version1029Date20231004091403' => __DIR__ . '/..' . '/../lib/Migration/Version1029Date20231004091403.php',
372373
'OCA\\DAV\\Migration\\Version1030Date20240205103243' => __DIR__ . '/..' . '/../lib/Migration/Version1030Date20240205103243.php',
373374
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => __DIR__ . '/..' . '/../lib/Migration/Version1031Date20240610134258.php',
374-
'OCA\\DAV\\Migration\\Version1032Date20250701000000' => __DIR__ . '/..' . '/../lib/Migration/Version1032Date20250701000000.php',
375375
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250813093701.php',
376376
'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php',
377377
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php',

apps/dav/lib/Migration/Version1032Date20250701000000.php renamed to apps/dav/lib/Migration/DisableSystemAddressBook.php

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,59 @@
44

55
/**
66
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7-
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
* SPDX-License-Identifier: AGPL-3.0-later
88
*/
9-
109
namespace OCA\DAV\Migration;
1110

12-
use Closure;
1311
use OCA\DAV\AppInfo\Application;
1412
use OCP\AppFramework\Services\IAppConfig;
1513
use OCP\IGroupManager;
1614
use OCP\IUserManager;
1715
use OCP\Migration\IOutput;
18-
use OCP\Migration\SimpleMigrationStep;
16+
use OCP\Migration\IRepairStep;
1917
use OCP\Notification\IManager;
20-
use Psr\Log\LoggerInterface;
18+
use OCP\ServerVersion;
2119

22-
class Version1032Date20250701000000 extends SimpleMigrationStep {
20+
class DisableSystemAddressBook implements IRepairStep {
2321

2422
public function __construct(
23+
private readonly ServerVersion $serverVersion,
2524
private readonly IAppConfig $appConfig,
2625
private readonly IUserManager $userManager,
2726
private readonly IGroupManager $groupManager,
2827
private readonly IManager $notificationManager,
29-
private readonly LoggerInterface $logger,
3028
) {
3129
}
3230

33-
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function getName() {
35+
return 'Disable system address book';
36+
}
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
public function run(IOutput $output) {
42+
$output->info("Running repair step to disable system address book");
43+
if ($this->serverVersion->getMajorVersion() !== 32) {
44+
$output->info("Skipping repair step system address book this only applies to Nextcloud 32");
45+
return;
46+
}
3447
// If the system address book is not exposed there is nothing to do
3548
if ($this->appConfig->getAppValueBool('system_addressbook_exposed', true) === false) {
49+
$output->info("Skipping repair step system address book is already disabled");
3650
return;
3751
}
3852
// We use count seen because getting a user count from the backend can be very slow
3953
$limit = $this->appConfig->getAppValueInt('system_addressbook_limit', 5000);
4054
if ($this->userManager->countSeenUsers() <= $limit) {
55+
$output->info("Skipping repair step system address book has less then the threshold $limit of contacts no need to disable");
4156
return;
4257
}
4358
$this->appConfig->setAppValueBool('system_addressbook_exposed', false);
44-
$this->logger->warning('System address book disabled because user limit reached');
59+
$output->warning("System address book disabled because it has more then the threshold of $limit contacts this can be re-enabled later");
4560
// Notify all admin users about the system address book being disabled
4661
foreach ($this->groupManager->get('admin')->getUsers() as $user) {
4762
$notification = $this->notificationManager->createNotification();
@@ -52,5 +67,4 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
5267
$this->notificationManager->notify($notification);
5368
}
5469
}
55-
5670
}

0 commit comments

Comments
 (0)