fix: Fix re-enabling the system address book

When "system_addressbook_exposed" is set through the administration
settings it is set as a boolean value in IAppConfig which, in the end,
stores it as "0" or "1". However, when read from IConfig in
UserAddressBooks it was strictly compared against "yes", so even if
explicitly enabled the comparison always failed and the system address
book was always seen as disabled. To solve that now the comparison is
made against a boolean value in IAppConfig, which is also consistent
with other places where the value is got (like ContactsManager).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2026-04-28 08:50:51 +02:00
parent f47db8ca3d
commit b26329e0d4
2 changed files with 6 additions and 4 deletions

View file

@ -14,6 +14,7 @@ use OCA\DAV\CardDAV\Integration\ExternalAddressBook;
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;
@ -37,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,
@ -48,6 +52,7 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
$this->l10n = Util::getL10N('dav');
$this->config = Server::get(IConfig::class);
$this->appConfig = Server::get(IAppConfig::class);
}
/**
@ -61,7 +66,7 @@ class UserAddressBooks extends \Sabre\CardDAV\AddressBookHome {
$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) {

View file

@ -592,9 +592,6 @@
</DeprecatedMethod>
</file>
<file src="apps/dav/lib/CardDAV/UserAddressBooks.php">
<DeprecatedMethod>
<code><![CDATA[getAppValue]]></code>
</DeprecatedMethod>
<InvalidArgument>
<code><![CDATA[$this->principalUri]]></code>
<code><![CDATA[$this->principalUri]]></code>