From 2da5e5fa512d92a1e0d5752a7654812abab6ccad Mon Sep 17 00:00:00 2001 From: Omar Date: Tue, 17 Jun 2025 14:48:13 +0000 Subject: [PATCH 1/3] Actualiser .github/workflows/ppd.yml --- .github/workflows/ppd.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ppd.yml b/.github/workflows/ppd.yml index 97e04f25..8cb3d90a 100644 --- a/.github/workflows/ppd.yml +++ b/.github/workflows/ppd.yml @@ -18,16 +18,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Setup SSH - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts - env: - SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} - - name: Copy SSH - run: cp ~/.ssh/id_rsa id_rsa + #- name: Setup SSH + # run: | + # mkdir -p ~/.ssh + # echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + # chmod 600 ~/.ssh/id_rsa + # ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts + # env: + # SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + #- name: Copy SSH + # run: cp ~/.ssh/id_rsa id_rsa - name: Login to Scaleway Container Registry uses: docker/login-action@v3 with: From b70dee2afebd1a5333db8ac6657d71c2065203b5 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 18 Jul 2025 14:30:06 +0200 Subject: [PATCH 2/3] [bug] Don't count refused documents when anchoring --- .../notary/OfficeFolderAnchorsController.ts | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/app/api/notary/OfficeFolderAnchorsController.ts b/src/app/api/notary/OfficeFolderAnchorsController.ts index bf8141ed..3f84a5bd 100644 --- a/src/app/api/notary/OfficeFolderAnchorsController.ts +++ b/src/app/api/notary/OfficeFolderAnchorsController.ts @@ -2,7 +2,7 @@ import { Response, Request } from "express"; import { Controller, Get, Post } from "@ControllerPattern/index"; import ApiController from "@Common/system/controller-pattern/ApiController"; import { Service } from "typedi"; -import { Document, OfficeFolder } from "le-coffre-resources/dist/Notary"; +import { Document, OfficeFolder, File } from "le-coffre-resources/dist/Notary"; import { getFolderHashes, getFolderFilesUid } from "@Common/optics/notary"; import OfficeFoldersService from "@Services/notary/OfficeFoldersService/OfficeFoldersService"; import OfficeFolderAnchorsRepository from "@Repositories/OfficeFolderAnchorsRepository"; @@ -162,24 +162,34 @@ export default class OfficeFoldersController extends ApiController { const officeFolder = OfficeFolder.hydrate(officeFolderFound, { strategy: "excludeAll" }); - // Check if every document is validated in a folder const documents = officeFolder.documents ?? []; - const documentsValidated = documents.filter((document) => { - let documentHydrated = Document.hydrate(document, { strategy: "excludeAll" }); - return documentHydrated.document_status === "VALIDATED"; + + if (documents.length === 0) { + this.httpBadRequest(response, "OfficeFolder has no documents at all"); + return; + } + + const hasInvalidDocument = documents.some((document: any) => { + const documentHydrated = Document.hydrate(document, { strategy: "excludeAll" }); + return documentHydrated.document_status !== "VALIDATED" && + documentHydrated.document_status !== "REFUSED"; }); - if (documentsValidated.length !== documents.length && documents.length !== 0) { - this.httpBadRequest(response, "Cannot anchor a folder with non validated documents"); + if (hasInvalidDocument) { + this.httpBadRequest(response, "OfficeFolder has non validated documents"); return; } - const folderHashes = getFolderHashes(officeFolder); - - if (folderHashes.length === 0) { - this.httpNotFoundRequest(response, "No file hash to anchor"); - 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); + }); + } + }); const sortedHashes = [...folderHashes].sort(); const data = await this.secureService.anchor(sortedHashes); From 86725b53fe1d181495349c6b9319b67f39b70b63 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 18 Jul 2025 19:15:42 +0200 Subject: [PATCH 3/3] 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");