Only take VALIDATED documents hash in get
All checks were successful
Demo - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 15s
Demo - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Demo - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 3s

This commit is contained in:
Sosthene 2025-07-18 19:15:42 +02:00
parent b70dee2afe
commit 86725b53fe

View File

@ -240,7 +240,24 @@ export default class OfficeFoldersController extends ApiController {
}
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
const folderHashes = getFolderHashes(officeFolder);
const documents = officeFolder.documents ?? [];
if (documents.length === 0) {
this.httpNotFoundRequest(response, "Office folder has no documents");
return;
}
const folderHashes: string[] = [];
documents.forEach((document: any) => {
const documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
if (documentHydrated.document_status === "VALIDATED") {
documentHydrated.files?.forEach((file: any) => {
const fileHydrated = File.hydrate<File>(file, { strategy: "excludeAll" });
folderHashes.push(fileHydrated.hash);
});
}
});
if (folderHashes.length === 0) {
this.httpNotFoundRequest(response, "No file hash to anchor");