Skip to content
Snippets Groups Projects
Commit 1efa5397 authored by Guillaume Heurtier's avatar Guillaume Heurtier
Browse files

FEAT #13119 TIME 0:45 added document information route

parent 171cf8cd
No related branches found
No related tags found
No related merge requests found
......@@ -379,6 +379,7 @@ $app->get('/resources/{resId}/emailsInitialization', \Email\controllers\EmailCon
$app->get('/resources/{resId}/fields/{fieldId}', \Resource\controllers\ResController::class . ':getField');
$app->delete('/resources/{resId}/linkedResources/{id}', \Resource\controllers\LinkController::class . ':unlinkResources');
$app->delete('/resources/{resId}/circuits/{type}', \Entity\controllers\ListInstanceController::class . ':deleteCircuit');
$app->get('/resources/{resId}/fileInformation', \Resource\controllers\ResController::class . ':getResourceFileInformation');
$app->put('/res/resource/status', \Resource\controllers\ResController::class . ':updateStatus');
$app->post('/res/list', \Resource\controllers\ResController::class . ':getList');
......
......@@ -1232,4 +1232,23 @@ class ResController extends ResourceControlController
return $response->withJson(['listEventData' => $listEventData]);
}
public function getResourceFileInformation(Request $request, Response $response, array $args)
{
if (!ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
$resource = ResModel::getById([
'resId' => $args['resId'],
'select' => ['format', 'fingerprint', 'filesize', 'fulltext_result']
]);
$allowedFiles = StoreController::getAllowedFiles();
$allowedFiles = array_column($allowedFiles, 'extension');
$resource['canConvert'] = in_array(strtoupper($resource['format']), $allowedFiles);
return $response->withJson(['information' => $resource]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment