Skip to content
Snippets Groups Projects
Commit efc1dd6b authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FEAT #18282 TIME 0:30 fixed provided versions for /rest/content and /rest/originalContent

parent cf009ccc
Branches
Tags
No related merge requests found
......@@ -440,13 +440,24 @@ class ResController extends ResourceControlController
} elseif (empty($document['filename'])) {
return $response->withStatus(400)->withJson(['errors' => 'Document has no file']);
}
$originalFormat = $document['format'];
$creatorId = $document['typist'];
$subject = $document['subject'];
$convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => 'letterbox_coll']);
if (!empty($convertedDocument['errors'])) {
return $response->withStatus(400)->withJson(['errors' => 'Conversion error : ' . $convertedDocument['errors']]);
$signedDocument = AdrModel::getDocuments([
'select' => ['id', 'docserver_id', 'path', 'filename', 'fingerprint'],
'where' => ['res_id = ?', 'type = ?', 'version = ?'],
'data' => [$args['resId'], 'SIGN', $document['version']],
'limit' => 1
]);
if (!empty($signedDocument[0]) && !empty($signedDocuments[0]['id'])) {
$convertedDocument = $signedDocument[0];
} else {
$convertedDocument = ConvertPdfController::getConvertedPdfById(['resId' => $aArgs['resId'], 'collId' => 'letterbox_coll']);
if (!empty($convertedDocument['errors'])) {
return $response->withStatus(400)->withJson(['errors' => 'Conversion error : ' . $convertedDocument['errors']]);
}
}
$document = $convertedDocument;
......@@ -648,14 +659,6 @@ class ResController extends ResourceControlController
}
$subject = $document['subject'];
$convertedDocument = AdrModel::getDocuments([
'select' => ['docserver_id', 'path', 'filename', 'fingerprint'],
'where' => ['res_id = ?', 'type = ?', 'version = ?'],
'data' => [$args['resId'], 'SIGN', $document['version']],
'limit' => 1
]);
$document = $convertedDocument[0] ?? $document;
$docserver = DocserverModel::getByDocserverId(['docserverId' => $document['docserver_id'], 'select' => ['path_template', 'docserver_type_id']]);
if (empty($docserver['path_template']) || !file_exists($docserver['path_template'])) {
return $response->withStatus(400)->withJson(['errors' => 'Docserver does not exist']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment