Skip to content

Commit c7748ae

Browse files
fix: normalize metadata contract fields in envelope child data
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 890453e commit c7748ae

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/Service/File/EnvelopeAssembler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ public function buildEnvelopeChildData(File $childFile, \OCA\Libresign\Service\F
4040
$fileData->status = $childFile->getStatus();
4141
$fileData->statusText = $this->fileMapper->getTextOfStatus($childFile->getStatus());
4242
$fileData->nodeId = $childFile->getNodeId();
43-
$fileData->metadata = $childFile->getMetadata();
4443
$childMetadata = $childFile->getMetadata() ?? [];
4544
$fileData->totalPages = (int)($childMetadata['p'] ?? 0);
4645
$fileData->pdfVersion = (string)($childMetadata['pdfVersion'] ?? '');
4746

47+
$childMetadata['p'] = $fileData->totalPages;
48+
$extension = pathinfo($childFile->getName(), PATHINFO_EXTENSION);
49+
if (!isset($childMetadata['extension']) || !is_string($childMetadata['extension']) || trim($childMetadata['extension']) === '') {
50+
$childMetadata['extension'] = is_string($extension) && $extension !== '' ? strtolower($extension) : 'pdf';
51+
}
52+
$fileData->metadata = $childMetadata;
53+
4854
$nodeId = $childFile->getSignedNodeId() ?: $childFile->getNodeId();
4955
$fileNode = $this->root->getUserFolder($childFile->getUserId())->getFirstNodeById($nodeId);
5056
if ($fileNode instanceof \OCP\Files\File) {

0 commit comments

Comments
 (0)