Skip to content

Commit ee0d187

Browse files
committed
feat(cloud_federation_api): support multi protocol for share creation
Signed-off-by: Enrique Pérez Arnaud <[email protected]>
1 parent 0efe763 commit ee0d187

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

apps/cloud_federation_api/lib/Controller/RequestHandlerController.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function __construct(
9494
* @param string|null $ownerDisplayName Display name of the user who shared the item
9595
* @param string|null $sharedBy Provider specific UID of the user who shared the resource
9696
* @param string|null $sharedByDisplayName Display name of the user who shared the resource
97-
* @param array{name: string, options?: array<string, mixed>, webdav?: array<string, mixed>} $protocol Old format: ['name' => 'webdav', 'options' => ['sharedSecret' => '...', 'permissions' => '...']] or New format: ['name' => 'webdav', 'webdav' => ['uri' => '...', 'sharedSecret' => '...', 'permissions' => [...]]]
97+
* @param array{name: string, options?: array<string, mixed>, webdav?: array<string, mixed>} $protocol Old format: ['name' => 'webdav', 'options' => ['sharedSecret' => '...', 'permissions' => '...']] or New format: ['name' => 'webdav', 'webdav' => ['uri' => '...', 'sharedSecret' => '...', 'permissions' => [...]]] or Multi format: ['name' => 'multi', 'webdav' => [...]]
9898
* @param string $shareType 'group' or 'user' share
9999
* @param string $resourceType 'file', 'calendar',...
100100
*
@@ -143,7 +143,20 @@ public function addShare($shareWith, $name, $description, $providerId, $owner, $
143143
$hasOldFormat = isset($protocol['options']) && is_array($protocol['options']) && isset($protocol['options']['sharedSecret']);
144144
$hasNewFormat = isset($protocol[$protocolName]) && is_array($protocol[$protocolName]) && isset($protocol[$protocolName]['sharedSecret']);
145145

146-
if (!$hasOldFormat && !$hasNewFormat) {
146+
// For multi-protocol, we only consider webdav
147+
$hasMultiFormat = false;
148+
if ($protocolName === 'multi') {
149+
if (isset($protocol['webdav']) && is_array($protocol['webdav']) && isset($protocol['webdav']['sharedSecret'])) {
150+
$hasMultiFormat = true;
151+
$protocol = [
152+
'name' => 'webdav',
153+
'webdav' => $protocol['webdav']
154+
];
155+
$protocolName = 'webdav';
156+
}
157+
}
158+
159+
if (!$hasOldFormat && !$hasNewFormat && !$hasMultiFormat) {
147160
return new JSONResponse(
148161
[
149162
'message' => 'Missing sharedSecret in protocol',

0 commit comments

Comments
 (0)