aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/OCM/Model/OCMProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/OCM/Model/OCMProvider.php')
-rw-r--r--lib/private/OCM/Model/OCMProvider.php94
1 files changed, 74 insertions, 20 deletions
diff --git a/lib/private/OCM/Model/OCMProvider.php b/lib/private/OCM/Model/OCMProvider.php
index f4b0ac584de..be13d65a40f 100644
--- a/lib/private/OCM/Model/OCMProvider.php
+++ b/lib/private/OCM/Model/OCMProvider.php
@@ -11,18 +11,22 @@ namespace OC\OCM\Model;
use NCU\Security\Signature\Model\Signatory;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\IConfig;
use OCP\OCM\Events\ResourceTypeRegisterEvent;
use OCP\OCM\Exceptions\OCMArgumentException;
use OCP\OCM\Exceptions\OCMProviderException;
-use OCP\OCM\IOCMProvider;
+use OCP\OCM\ICapabilityAwareOCMProvider;
use OCP\OCM\IOCMResource;
/**
* @since 28.0.0
*/
-class OCMProvider implements IOCMProvider {
+class OCMProvider implements ICapabilityAwareOCMProvider {
+ private string $provider;
private bool $enabled = false;
private string $apiVersion = '';
+ private string $inviteAcceptDialog = '';
+ private array $capabilities = [];
private string $endPoint = '';
/** @var IOCMResource[] */
private array $resourceTypes = [];
@@ -31,7 +35,9 @@ class OCMProvider implements IOCMProvider {
public function __construct(
protected IEventDispatcher $dispatcher,
+ protected IConfig $config,
) {
+ $this->provider = 'Nextcloud ' . $config->getSystemValue('version');
}
/**
@@ -71,6 +77,30 @@ class OCMProvider implements IOCMProvider {
}
/**
+ * returns the invite accept dialog
+ *
+ * @return string
+ * @since 32.0.0
+ */
+ public function getInviteAcceptDialog(): string {
+ return $this->inviteAcceptDialog;
+ }
+
+ /**
+ * set the invite accept dialog
+ *
+ * @param string $inviteAcceptDialog
+ *
+ * @return $this
+ * @since 32.0.0
+ */
+ public function setInviteAcceptDialog(string $inviteAcceptDialog): static {
+ $this->inviteAcceptDialog = $inviteAcceptDialog;
+
+ return $this;
+ }
+
+ /**
* @param string $endPoint
*
* @return $this
@@ -89,6 +119,34 @@ class OCMProvider implements IOCMProvider {
}
/**
+ * @return string
+ */
+ public function getProvider(): string {
+ return $this->provider;
+ }
+
+ /**
+ * @param array $capabilities
+ *
+ * @return $this
+ */
+ public function setCapabilities(array $capabilities): static {
+ foreach ($capabilities as $value) {
+ if (!in_array($value, $this->capabilities)) {
+ array_push($this->capabilities, $value);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getCapabilities(): array {
+ return $this->capabilities;
+ }
+ /**
* create a new resource to later add it with {@see IOCMProvider::addResourceType()}
* @return IOCMResource
*/
@@ -166,9 +224,8 @@ class OCMProvider implements IOCMProvider {
*
* @param array $data
*
- * @return $this
+ * @return OCMProvider&static
* @throws OCMProviderException in case a descent provider cannot be generated from data
- * @see self::jsonSerialize()
*/
public function import(array $data): static {
$this->setEnabled(is_bool($data['enabled'] ?? '') ? $data['enabled'] : false)
@@ -209,21 +266,7 @@ class OCMProvider implements IOCMProvider {
}
/**
- * @return array{
- * enabled: bool,
- * apiVersion: '1.0-proposal1',
- * endPoint: string,
- * publicKey?: array{
- * keyId: string,
- * publicKeyPem: string
- * },
- * resourceTypes: list<array{
- * name: string,
- * shareTypes: list<string>,
- * protocols: array<string, string>
- * }>,
- * version: string
- * }
+ * @since 28.0.0
*/
public function jsonSerialize(): array {
$resourceTypes = [];
@@ -231,7 +274,7 @@ class OCMProvider implements IOCMProvider {
$resourceTypes[] = $res->jsonSerialize();
}
- return [
+ $response = [
'enabled' => $this->isEnabled(),
'apiVersion' => '1.0-proposal1', // deprecated, but keep it to stay compatible with old version
'version' => $this->getApiVersion(), // informative but real version
@@ -239,5 +282,16 @@ class OCMProvider implements IOCMProvider {
'publicKey' => $this->getSignatory()?->jsonSerialize(),
'resourceTypes' => $resourceTypes
];
+
+ $capabilities = $this->getCapabilities();
+ $inviteAcceptDialog = $this->getInviteAcceptDialog();
+ if ($capabilities) {
+ $response['capabilities'] = $capabilities;
+ }
+ if ($inviteAcceptDialog) {
+ $response['inviteAcceptDialog'] = $inviteAcceptDialog;
+ }
+ return $response;
+
}
}