From 86725b53fe1d181495349c6b9319b67f39b70b63 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 18 Jul 2025 19:15:42 +0200 Subject: [PATCH] Only take VALIDATED documents hash in get --- .../notary/OfficeFolderAnchorsController.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/api/notary/OfficeFolderAnchorsController.ts b/src/app/api/notary/OfficeFolderAnchorsController.ts index 3f84a5bd..8cedd895 100644 --- a/src/app/api/notary/OfficeFolderAnchorsController.ts +++ b/src/app/api/notary/OfficeFolderAnchorsController.ts @@ -240,7 +240,24 @@ export default class OfficeFoldersController extends ApiController { } const officeFolder = OfficeFolder.hydrate(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, { strategy: "excludeAll" }); + if (documentHydrated.document_status === "VALIDATED") { + documentHydrated.files?.forEach((file: any) => { + const fileHydrated = File.hydrate(file, { strategy: "excludeAll" }); + folderHashes.push(fileHydrated.hash); + }); + } + }); if (folderHashes.length === 0) { this.httpNotFoundRequest(response, "No file hash to anchor");