mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
chore(absence): Add capability for absence api
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
parent
e17f011f08
commit
66d4f0e4c0
4 changed files with 43 additions and 3 deletions
|
|
@ -7,15 +7,17 @@ namespace OCA\DAV;
|
|||
|
||||
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 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@
|
|||
},
|
||||
"bulkupload": {
|
||||
"type": "string"
|
||||
},
|
||||
"absence-supported": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ use OCA\DAV\Capabilities;
|
|||
use OCP\AppFramework\QueryException;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class NotificationProviderManagerTest extends TestCase {
|
||||
|
||||
/** @var NotificationProviderManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue