diff --git a/apps/dav/lib/CardDAV/UserAddressBooks.php b/apps/dav/lib/CardDAV/UserAddressBooks.php index e29e52e77dffd..f78afff7cbbc6 100644 --- a/apps/dav/lib/CardDAV/UserAddressBooks.php +++ b/apps/dav/lib/CardDAV/UserAddressBooks.php @@ -14,6 +14,7 @@ use OCA\DAV\CardDAV\Integration\IAddressBookProvider; use OCA\Federation\TrustedServers; use OCP\AppFramework\QueryException; +use OCP\IAppConfig; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; @@ -21,6 +22,7 @@ use OCP\IUser; use OCP\IUserSession; use OCP\Server; +use OCP\Util; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Sabre\CardDAV\Backend; @@ -36,6 +38,9 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome { /** @var IConfig */ protected $config; + /** @var IAppConfig */ + protected $appConfig; + public function __construct( Backend\BackendInterface $carddavBackend, string $principalUri, @@ -44,6 +49,10 @@ public function __construct( private ?IGroupManager $groupManager, ) { parent::__construct($carddavBackend, $principalUri); + + $this->l10n = Util::getL10N('dav'); + $this->config = Server::get(IConfig::class); + $this->appConfig = Server::get(IAppConfig::class); } /** @@ -52,19 +61,12 @@ public function __construct( * @return IAddressBook[] */ public function getChildren() { - if ($this->l10n === null) { - $this->l10n = \OC::$server->getL10N('dav'); - } - if ($this->config === null) { - $this->config = Server::get(IConfig::class); - } - /** @var string|array $principal */ $principal = $this->principalUri; $addressBooks = $this->carddavBackend->getAddressBooksForUser($this->principalUri); // add the system address book $systemAddressBook = null; - $systemAddressBookExposed = $this->config->getAppValue('dav', 'system_addressbook_exposed', 'yes') === 'yes'; + $systemAddressBookExposed = $this->appConfig->getValueBool('dav', 'system_addressbook_exposed', true); if ($systemAddressBookExposed && is_string($principal) && $principal !== 'principals/system/system' && $this->carddavBackend instanceof CardDavBackend) { $systemAddressBook = $this->carddavBackend->getAddressBooksByUri('principals/system/system', 'system'); if ($systemAddressBook !== null) { diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index b44e18ea114e2..b92298da7d122 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -592,10 +592,6 @@ - - - - principalUri]]> principalUri]]>