diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-04 17:07:24 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-04 17:07:24 +0200 |
commit | 63052522a2ea349d4d2c6a2c02f0ba97d83f6078 (patch) | |
tree | da6b6ab1af29e9776ba7e68d6e66b59f7f0c6182 | |
parent | a35f4b16ac42ed73d7b540e40b72aaa160051f0f (diff) | |
download | nextcloud-server-perf/capa.tar.gz nextcloud-server-perf/capa.zip |
perf(cloud_federation_api): only provide capabilities if neededperf/capa
The capabilities can be quite expensive (e.g. on ARM board it takes 1s
per request only for the capabilities).
Also they are not used by the webui so they should not be included in
initial state.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/cloud_federation_api/lib/Capabilities.php | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/cloud_federation_api/lib/Capabilities.php b/apps/cloud_federation_api/lib/Capabilities.php index 8957fb8b9d8..0348f6e7c11 100644 --- a/apps/cloud_federation_api/lib/Capabilities.php +++ b/apps/cloud_federation_api/lib/Capabilities.php @@ -12,13 +12,14 @@ use NCU\Security\Signature\Exceptions\IdentityNotFoundException; use NCU\Security\Signature\Exceptions\SignatoryException; use OC\OCM\OCMSignatoryManager; use OCP\Capabilities\ICapability; +use OCP\Capabilities\IInitialStateExcludedCapability; use OCP\IAppConfig; use OCP\IURLGenerator; use OCP\OCM\Exceptions\OCMArgumentException; use OCP\OCM\IOCMProvider; use Psr\Log\LoggerInterface; -class Capabilities implements ICapability { +class Capabilities implements ICapability, IInitialStateExcludedCapability { public const API_VERSION = '1.1'; // informative, real version. public function __construct( @@ -54,15 +55,13 @@ class Capabilities implements ICapability { */ public function getCapabilities() { $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); - - $this->provider->setEnabled(true); - $this->provider->setApiVersion(self::API_VERSION); - $pos = strrpos($url, '/'); if ($pos === false) { - throw new OCMArgumentException('generated route should contains a slash character'); + throw new OCMArgumentException('generated route should contain a slash character'); } + $this->provider->setEnabled(true); + $this->provider->setApiVersion(self::API_VERSION); $this->provider->setEndPoint(substr($url, 0, $pos)); $resource = $this->provider->createNewResourceType(); @@ -87,6 +86,6 @@ class Capabilities implements ICapability { $this->logger->warning('cannot generate local signatory', ['exception' => $e]); } - return ['ocm' => json_decode(json_encode($this->provider->jsonSerialize()), true)]; + return ['ocm' => $this->provider->jsonSerialize()]; } } |