From 5fdcb79ebf9d76af9ac7f9bb56ed788210616597 Mon Sep 17 00:00:00 2001 From: Micke Nordin Date: Thu, 15 Aug 2024 17:33:49 +0200 Subject: [PATCH] feat(FederatedFileSharing): Allow CloudFederationProviderFiles to accept OCM 1.1.0 shares Signed-off-by: Micke Nordin --- .../lib/OCM/CloudFederationProviderFiles.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index e1bbbbc310f6c..e3d15e933c46d 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -88,7 +88,27 @@ public function shareReceived(ICloudFederationShare $share) { } $protocol = $share->getProtocol(); - if ($protocol['name'] !== 'webdav') { + $name = ''; + if (array_key_exists('name', $protocol)) { + // OCM 1.0.0 https://cs3org.github.io/OCM-API/docs.html?branch=v1.0.0&repo=OCM-API&user=cs3org#/paths/~1shares/post + $name = $protocol['name']; + } else { + // OCM 1.1.0 https://cs3org.github.io/OCM-API/docs.html?branch=v1.1.0&repo=OCM-API&user=cs3org#/paths/~1shares/post + if (array_key_exists('singleProtocolLegacy', $protocol)) { + $name = $protocol['singleProtocolLegacy']['name']; + } + elseif (array_key_exists('singleProtocolLegacy', $protocol)) { + $name = $protocol['singleProtocolNew']['name']; + } + elseif (array_key_exists('multipleProtocols', $protocol)) { + if(array_key_exists('webdav', $protocol['multipleProtocols'])) { + $name = 'webdav'; + } + } + } + + + if ($name !== 'webdav') { throw new ProviderCouldNotAddShareException('Unsupported protocol for data exchange.', '', Http::STATUS_NOT_IMPLEMENTED); } @@ -212,6 +232,7 @@ public function notificationReceived($notificationType, $providerId, array $noti return $this->undoReshare($providerId, $notification); case 'RESHARE_CHANGE_PERMISSION': return $this->updateResharePermissions($providerId, $notification); + // TODO: Implement USER_REMOVED }