diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php index 76530353613c4..6b623c66b5512 100644 --- a/lib/private/OCM/Model/OCMProvider.php +++ b/lib/private/OCM/Model/OCMProvider.php @@ -21,6 +21,8 @@ */ class OCMProvider implements IOCMProvider { private bool $enabled = false; + private bool $removePublicKey = false; + private bool $removeVersion = false; private string $apiVersion = ''; private string $inviteAcceptDialog = ''; private array $capabilities = []; @@ -326,6 +328,22 @@ private function looksValid(): bool { return ($this->getApiVersion() !== '' && $this->getEndPoint() !== ''); } + /** + * @since 35.0.0 + */ + #[\Override] + public function removePublicKey(): void { + $this->removePublicKey = true; + } + + /** + * @since 35.0.0 + */ + #[\Override] + public function removeVersion(): void { + $this->removeVersion = true; + } + /** * @since 28.0.0 */ @@ -346,6 +364,15 @@ public function jsonSerialize(): array { 'resourceTypes' => $resourceTypes ]; + if ($this->removeVersion) { + $response['apiVersion'] = $this->getApiVersion(); + unset($response['version']); + } + + if ($this->removePublicKey) { + unset($response['publicKey']); + } + if ($this->capabilities !== []) { $response['capabilities'] = $this->capabilities; } diff --git a/lib/public/OCM/Events/LocalOCMDiscoveryEvent.php b/lib/public/OCM/Events/LocalOCMDiscoveryEvent.php index a6ef943145b17..cb63d0c05060b 100644 --- a/lib/public/OCM/Events/LocalOCMDiscoveryEvent.php +++ b/lib/public/OCM/Events/LocalOCMDiscoveryEvent.php @@ -54,4 +54,34 @@ public function registerResourceType(string $name, array $shareTypes, array $pro ->setProtocols($protocols); $this->provider->addResourceType($resourceType); } + + /** + * Remove the non-standard publicKey field from OCM discovery + * + * @since 35.0.0 + */ + public function removePublicKey(): void { + $this->provider->removePublicKey(); + } + + /** + * Remove the non-standard version field from OCM discovery + * + * @since 35.0.0 + */ + public function removeVersion(): void { + $this->provider->removeVersion(); + } + + /** + * Set the apiVersion + * + * @param string $version + * + * @since 35.0.0 + */ + public function setApiVersion(string $version): void { + $this->provider->setApiVersion($version); + } + } diff --git a/lib/public/OCM/IOCMProvider.php b/lib/public/OCM/IOCMProvider.php index bcda666578438..3cf7f60c09012 100644 --- a/lib/public/OCM/IOCMProvider.php +++ b/lib/public/OCM/IOCMProvider.php @@ -57,6 +57,20 @@ public function setApiVersion(string $apiVersion): static; */ public function getApiVersion(): string; + /** + * Remove the non-standard publicKey field from OCM discovery + * + * @since 35.0.0 + */ + public function removePublicKey(): void; + + /** + * Remove the non-standard version field from OCM discovery + * + * @since 35.0.0 + */ + public function removeVersion(): void; + /** * configure endpoint * @@ -219,7 +233,7 @@ public function import(array $data): static; /** * @return array{ * enabled: bool, - * apiVersion: '1.0-proposal1', + * apiVersion: string, * endPoint: string, * publicKey?: array{ * keyId: string, @@ -230,7 +244,7 @@ public function import(array $data): static; * shareTypes: list, * protocols: array * }>, - * version: string + * version?: string * } * @since 28.0.0 */