Skip to content

Commit 1047aa8

Browse files
committed
fix: support uploadedFile in single file save flow
Added handling for uploadedFile case in prepareFileForSaving method. When a single file is uploaded via file upload, it now correctly validates and creates the node using the uploadedFile data. Also fixed list endpoint to skip envelopes when loading user settings, preventing 'File not found' errors for envelope nodes. Signed-off-by: Vitor Mattos <[email protected]>
1 parent 9220837 commit 1047aa8

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

lib/Controller/FileController.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,16 +281,25 @@ public function list(
281281
$return = $this->fileService->listAssociatedFilesOfSignFlow($page, $length, $filter, $sort);
282282

283283
if ($user && !empty($return['data'])) {
284-
$firstFile = $return['data'][0];
285-
$fileSettings = $this->fileService
286-
->setFileByType('FileId', $firstFile['nodeId'])
287-
->showSettings()
288-
->toArray();
284+
$firstFile = null;
285+
foreach ($return['data'] as $file) {
286+
if (($file['nodeType'] ?? 'file') !== 'envelope') {
287+
$firstFile = $file;
288+
break;
289+
}
290+
}
289291

290-
$return['settings'] = [
291-
'needIdentificationDocuments' => $fileSettings['settings']['needIdentificationDocuments'] ?? false,
292-
'identificationDocumentsWaitingApproval' => $fileSettings['settings']['identificationDocumentsWaitingApproval'] ?? false,
293-
];
292+
if ($firstFile) {
293+
$fileSettings = $this->fileService
294+
->setFileByType('FileId', $firstFile['nodeId'])
295+
->showSettings()
296+
->toArray();
297+
298+
$return['settings'] = [
299+
'needIdentificationDocuments' => $fileSettings['settings']['needIdentificationDocuments'] ?? false,
300+
'identificationDocumentsWaitingApproval' => $fileSettings['settings']['identificationDocumentsWaitingApproval'] ?? false,
301+
];
302+
}
294303
}
295304

296305
return new DataResponse($return, Http::STATUS_OK);
@@ -446,6 +455,15 @@ private function prepareFileForSaving(array $fileData, string $name, array $sett
446455
if (isset($fileData['fileNode']) && $fileData['fileNode'] instanceof Node) {
447456
$node = $fileData['fileNode'];
448457
$name = $fileData['name'] ?? $name;
458+
} elseif (isset($fileData['uploadedFile'])) {
459+
$this->fileService->validateUploadedFile($fileData['uploadedFile']);
460+
461+
$node = $this->fileService->getNodeFromData([
462+
'userManager' => $this->userSession->getUser(),
463+
'name' => $name,
464+
'uploadedFile' => $fileData['uploadedFile'],
465+
'settings' => $settings
466+
]);
449467
} else {
450468
$this->validateHelper->validateNewFile([
451469
'file' => $fileData,

0 commit comments

Comments
 (0)