diff --git a/apps/dav/lib/Capabilities.php b/apps/dav/lib/Capabilities.php index b0f63f80f2daf..36d56d4a822e1 100644 --- a/apps/dav/lib/Capabilities.php +++ b/apps/dav/lib/Capabilities.php @@ -7,15 +7,17 @@ use OCP\Capabilities\ICapability; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; class Capabilities implements ICapability { public function __construct( private IConfig $config, + private IAvailabilityCoordinator $coordinator, ) { } /** - * @return array{dav: array{chunking: string, bulkupload?: string}} + * @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool}} */ public function getCapabilities() { $capabilities = [ @@ -26,6 +28,9 @@ public function getCapabilities() { 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 7045a7f9b274c..e212796304d42 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 6c46a2aed2d50..6d0e62f505b52 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -17,6 +17,9 @@ use OCP\AppFramework\QueryException; 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 acdfb4a244324..3cd63159a212b 100644 --- a/apps/dav/tests/unit/CapabilitiesTest.php +++ b/apps/dav/tests/unit/CapabilitiesTest.php @@ -7,6 +7,7 @@ use OCA\DAV\Capabilities; use OCP\IConfig; +use OCP\User\IAvailabilityCoordinator; use Test\TestCase; /** @@ -19,7 +20,11 @@ public function testGetCapabilities(): void { ->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 @@ public function testGetCapabilitiesWithBulkUpload(): void { ->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 @@ public function testGetCapabilitiesWithBulkUpload(): void { ]; $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()); + } }