2018-04-30 10:29:56 -04:00
|
|
|
<?php
|
2023-09-05 08:42:48 -04:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-04-30 10:29:56 -04:00
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-04-30 10:29:56 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\CloudFederationAPI;
|
|
|
|
|
|
2025-08-20 11:41:06 -04:00
|
|
|
use OC\OCM\OCMDiscoveryService;
|
2018-04-30 10:29:56 -04:00
|
|
|
use OCP\Capabilities\ICapability;
|
2025-04-04 11:07:24 -04:00
|
|
|
use OCP\Capabilities\IInitialStateExcludedCapability;
|
2023-09-05 08:42:48 -04:00
|
|
|
use OCP\OCM\Exceptions\OCMArgumentException;
|
2018-04-30 10:29:56 -04:00
|
|
|
|
2025-04-04 11:07:24 -04:00
|
|
|
class Capabilities implements ICapability, IInitialStateExcludedCapability {
|
2023-09-05 08:42:48 -04:00
|
|
|
public function __construct(
|
2025-08-20 11:41:06 -04:00
|
|
|
private readonly OCMDiscoveryService $ocmDiscoveryService,
|
2023-09-05 08:42:48 -04:00
|
|
|
) {
|
2018-04-30 10:29:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Function an app uses to return the capabilities
|
2023-07-13 01:20:55 -04:00
|
|
|
*
|
|
|
|
|
* @return array{
|
|
|
|
|
* ocm: array{
|
2024-11-12 17:07:16 -05:00
|
|
|
* apiVersion: '1.0-proposal1',
|
2023-07-13 01:20:55 -04:00
|
|
|
* enabled: bool,
|
|
|
|
|
* endPoint: string,
|
2025-03-21 04:15:55 -04:00
|
|
|
* publicKey?: array{
|
2024-11-12 17:07:16 -05:00
|
|
|
* keyId: string,
|
|
|
|
|
* publicKeyPem: string,
|
|
|
|
|
* },
|
2024-09-24 09:53:13 -04:00
|
|
|
* resourceTypes: list<array{
|
2023-07-13 01:20:55 -04:00
|
|
|
* name: string,
|
2024-09-24 09:53:13 -04:00
|
|
|
* shareTypes: list<string>,
|
2023-09-05 08:42:48 -04:00
|
|
|
* protocols: array<string, string>
|
2024-11-12 17:07:16 -05:00
|
|
|
* }>,
|
|
|
|
|
* version: string
|
|
|
|
|
* }
|
2023-07-13 01:20:55 -04:00
|
|
|
* }
|
2023-09-05 08:42:48 -04:00
|
|
|
* @throws OCMArgumentException
|
2018-04-30 10:29:56 -04:00
|
|
|
*/
|
|
|
|
|
public function getCapabilities() {
|
2025-08-20 11:41:06 -04:00
|
|
|
$provider = $this->ocmDiscoveryService->getLocalOCMProvider(false);
|
|
|
|
|
return ['ocm' => $provider->jsonSerialize()];
|
2018-04-30 10:29:56 -04:00
|
|
|
}
|
|
|
|
|
}
|