diff options
author | Marcel Müller <marcel-mueller@gmx.de> | 2024-12-01 22:22:38 +0100 |
---|---|---|
committer | Marcel Müller <marcel-mueller@gmx.de> | 2024-12-13 07:46:20 +0100 |
commit | 235e1fb878529938b6ff459172bd12d1c016e46e (patch) | |
tree | a83302047e4da085400a0ea2ea2e5e746dda8076 /apps | |
parent | 0718ac7c927ab53c1d17b70eb8eb9f2a3b1a3f37 (diff) | |
download | nextcloud-server-235e1fb878529938b6ff459172bd12d1c016e46e.tar.gz nextcloud-server-235e1fb878529938b6ff459172bd12d1c016e46e.zip |
chore(absence): Add capability for absence api
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/Capabilities.php | 10 | ||||
-rw-r--r-- | apps/dav/openapi.json | 3 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php | 3 | ||||
-rw-r--r-- | apps/dav/tests/unit/CapabilitiesTest.php | 33 |
4 files changed, 45 insertions, 4 deletions
diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index 1de64e16e41..63f10eab58f 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -7,16 +7,19 @@ namespace OCA\DAV; use OCP\Capabilities\ICapability; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; class Capabilities implements ICapability { private IConfig $config; + private IAvailabilityCoordinator $coordinator; - public function __construct(IConfig $config) { + public function __construct(IConfig $config, IAvailabilityCoordinator $coordinator) { $this->config = $config; + $this->coordinator = $coordinator; } /** - * @return array{dav: array{chunking: string, bulkupload?: string}} + * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool}} */ public function getCapabilities() { $capabilities = [ @@ -27,6 +30,9 @@ class Capabilities implements ICapability { if ($this->config->getSystemValueBool('bulkupload.enabled', true)) { $capabilities['dav']['bulkupload'] = '1.0'; } + if ($this->coordinator->isEnabled()) { + $capabilities['dav']['absence-supported'] = true; + } return $capabilities; } } diff --git a/apps/dav/openapi.json b/apps/dav/openapi.json index 7045a7f9b27..e212796304d 100644 --- a/apps/dav/openapi.json +++ b/apps/dav/openapi.json @@ -37,6 +37,9 @@ }, "bulkupload": { "type": "string" + }, + "absence-supported": { + "type": "boolean" } } } diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index 98d49552b02..662bb89e6f5 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -16,6 +16,9 @@ use OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException; use OCA\DAV\Capabilities; use Test\TestCase; +/** + * @group DB + */ class NotificationProviderManagerTest extends TestCase { /** @var NotificationProviderManager|\PHPUnit\Framework\MockObject\MockObject */ diff --git a/apps/dav/tests/unit/CapabilitiesTest.php b/apps/dav/tests/unit/CapabilitiesTest.php index acdfb4a2443..4a2d7e8dba6 100644 --- a/apps/dav/tests/unit/CapabilitiesTest.php +++ b/apps/dav/tests/unit/CapabilitiesTest.php @@ -7,6 +7,7 @@ namespace OCA\DAV\Tests\unit; use OCA\DAV\Capabilities; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; use Test\TestCase; /** @@ -19,7 +20,11 @@ class CapabilitiesTest extends TestCase { ->method('getSystemValueBool') ->with('bulkupload.enabled', $this->isType('bool')) ->willReturn(false); - $capabilities = new Capabilities($config); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(false); + $capabilities = new Capabilities($config, $coordinator); $expected = [ 'dav' => [ 'chunking' => '1.0', @@ -34,7 +39,11 @@ class CapabilitiesTest extends TestCase { ->method('getSystemValueBool') ->with('bulkupload.enabled', $this->isType('bool')) ->willReturn(true); - $capabilities = new Capabilities($config); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(false); + $capabilities = new Capabilities($config, $coordinator); $expected = [ 'dav' => [ 'chunking' => '1.0', @@ -43,4 +52,24 @@ class CapabilitiesTest extends TestCase { ]; $this->assertSame($expected, $capabilities->getCapabilities()); } + + public function testGetCapabilitiesWithAbsence(): void { + $config = $this->createMock(IConfig::class); + $config->expects($this->once()) + ->method('getSystemValueBool') + ->with('bulkupload.enabled', $this->isType('bool')) + ->willReturn(false); + $coordinator = $this->createMock(IAvailabilityCoordinator::class); + $coordinator->expects($this->once()) + ->method('isEnabled') + ->willReturn(true); + $capabilities = new Capabilities($config, $coordinator); + $expected = [ + 'dav' => [ + 'chunking' => '1.0', + 'absence-supported' => true, + ], + ]; + $this->assertSame($expected, $capabilities->getCapabilities()); + } } |