-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Expand file tree
/
Copy pathSystemAddressBookSize.php
More file actions
54 lines (44 loc) · 1.55 KB
/
Copy pathSystemAddressBookSize.php
File metadata and controls
54 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\SetupChecks;
use OCA\DAV\AppInfo\Application;
use OCA\DAV\ConfigLexicon;
use OCP\IAppConfig;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\SetupCheck\ISetupCheck;
use OCP\SetupCheck\SetupResult;
class SystemAddressBookSize implements ISetupCheck {
public function __construct(
private IAppConfig $appConfig,
private IUserManager $userManager,
private IL10N $l10n,
) {
}
#[\Override]
public function getName(): string {
return $this->l10n->t('DAV system address book size');
}
#[\Override]
public function getCategory(): string {
return 'dav';
}
#[\Override]
public function run(): SetupResult {
if (!$this->appConfig->getValueBool(Application::APP_ID, ConfigLexicon::SYSTEM_ADDRESSBOOK_EXPOSED)) {
return SetupResult::success($this->l10n->t('The system address book is disabled'));
}
// We use count seen because getting a user count from the backend can be very slow
$count = $this->userManager->countSeenUsers();
$limit = $this->appConfig->getValueInt(Application::APP_ID, 'system_addressbook_limit', 5000);
if ($count > $limit) {
return SetupResult::warning($this->l10n->t('The system address book is enabled, but contains more than the configured limit of %d contacts', [$limit]));
} else {
return SetupResult::success($this->l10n->t('The system address book is enabled and contains less than the configured limit of %d contacts', [$limit]));
}
}
}