Skip to content

Commit c2040e5

Browse files
committed
fix: add status and created_at fields to file upload response
Return status, statusText and created_at in the API response after file upload to display immediately in the files list without needing to reload. Also removed unused etag, path and type fields. Uses FileMapper to get status text and returns FileEntity directly from save() method instead of additional database query. Signed-off-by: Vitor Mattos <[email protected]>
1 parent a8bb48e commit c2040e5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/Controller/FileController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\Files_Sharing\SharedStorage;
1313
use OCA\Libresign\AppInfo\Application;
1414
use OCA\Libresign\Db\File as FileEntity;
15+
use OCA\Libresign\Db\FileMapper;
1516
use OCA\Libresign\Db\SignRequestMapper;
1617
use OCA\Libresign\Exception\LibresignException;
1718
use OCA\Libresign\Helper\JSActions;
@@ -62,6 +63,7 @@ public function __construct(
6263
private IUserSession $userSession,
6364
private SessionService $sessionService,
6465
private SignRequestMapper $signRequestMapper,
66+
private FileMapper $fileMapper,
6567
private IdentifyMethodService $identifyMethodService,
6668
private RequestSignatureService $requestSignatureService,
6769
private AccountService $accountService,
@@ -438,16 +440,16 @@ public function save(array $file, string $name = '', array $settings = []): Data
438440
'userManager' => $this->userSession->getUser(),
439441
'status' => FileEntity::STATUS_DRAFT,
440442
];
441-
$this->requestSignatureService->save($data);
443+
$file = $this->requestSignatureService->save($data);
442444

443445
return new DataResponse(
444446
[
445447
'message' => $this->l10n->t('Success'),
446448
'name' => $name,
447449
'id' => $node->getId(),
448-
'etag' => $node->getEtag(),
449-
'path' => $node->getPath(),
450-
'type' => $node->getType(),
450+
'status' => $file->getStatus(),
451+
'statusText' => $this->fileMapper->getTextOfStatus($file->getStatus()),
452+
'created_at' => $file->getCreatedAt()->format(\DateTimeInterface::ATOM),
451453
],
452454
Http::STATUS_OK
453455
);

0 commit comments

Comments
 (0)