Skip to content

Commit 99135d6

Browse files
committed
feat: Add support for nodeId validation in ValidateHelper
Support validating files by Nextcloud nodeId in addition to LibreSign fileId. This enables creating signature requests for files that haven't been registered in LibreSign yet. The validateFile method now accepts 'nodeId' parameter and validates it similarly to 'fileId', ensuring the file exists and has the correct MIME type. Signed-off-by: Vitor Mattos <[email protected]>
1 parent a37e37f commit 99135d6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

lib/Helper/ValidateHelper.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ public function validateFile(array $data, int $type = self::TYPE_TO_SIGN, ?IUser
125125
}
126126
$this->validateIfNodeIdExists((int)$data['file']['fileId'], $data['userManager']->getUID(), $type);
127127
$this->validateMimeTypeAcceptedByNodeId((int)$data['file']['fileId'], $data['userManager']->getUID(), $type);
128+
} elseif (!empty($data['file']['nodeId'])) {
129+
if (!is_numeric($data['file']['nodeId'])) {
130+
throw new LibresignException($this->l10n->t('File type: %s. Invalid fileID.', [$this->getTypeOfFile($type)]));
131+
}
132+
if (!is_a($user, IUser::class)) {
133+
if (!is_a($data['userManager'], IUser::class)) {
134+
throw new LibresignException($this->l10n->t('User not found.'));
135+
}
136+
}
137+
$this->validateIfNodeIdExists((int)$data['file']['nodeId'], $data['userManager']->getUID(), $type);
138+
$this->validateMimeTypeAcceptedByNodeId((int)$data['file']['nodeId'], $data['userManager']->getUID(), $type);
128139
} elseif (!empty($data['file']['base64'])) {
129140
$this->validateBase64($data['file']['base64'], $type);
130141
} elseif (!empty($data['file']['path'])) {

0 commit comments

Comments
 (0)