Compare commits
No commits in common. "6fe554078464e0394039e105077ca6276b353eab" and "a2fef18b82afc3851249c7c8f815bdcdd2e0b57c" have entirely different histories.
6fe5540784
...
a2fef18b82
20
.github/workflows/ppd.yml
vendored
20
.github/workflows/ppd.yml
vendored
@ -18,16 +18,16 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
#- name: Setup SSH
|
- name: Setup SSH
|
||||||
# run: |
|
run: |
|
||||||
# mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
||||||
# chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
# ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
|
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
|
||||||
# env:
|
env:
|
||||||
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
#- name: Copy SSH
|
- name: Copy SSH
|
||||||
# run: cp ~/.ssh/id_rsa id_rsa
|
run: cp ~/.ssh/id_rsa id_rsa
|
||||||
- name: Login to Scaleway Container Registry
|
- name: Login to Scaleway Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
@ -2,7 +2,7 @@ import { Response, Request } from "express";
|
|||||||
import { Controller, Get, Post } from "@ControllerPattern/index";
|
import { Controller, Get, Post } from "@ControllerPattern/index";
|
||||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||||
import { Service } from "typedi";
|
import { Service } from "typedi";
|
||||||
import { Document, OfficeFolder, File } from "le-coffre-resources/dist/Notary";
|
import { Document, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
import { getFolderHashes, getFolderFilesUid } from "@Common/optics/notary";
|
import { getFolderHashes, getFolderFilesUid } from "@Common/optics/notary";
|
||||||
import OfficeFoldersService from "@Services/notary/OfficeFoldersService/OfficeFoldersService";
|
import OfficeFoldersService from "@Services/notary/OfficeFoldersService/OfficeFoldersService";
|
||||||
import OfficeFolderAnchorsRepository from "@Repositories/OfficeFolderAnchorsRepository";
|
import OfficeFolderAnchorsRepository from "@Repositories/OfficeFolderAnchorsRepository";
|
||||||
@ -162,35 +162,25 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
|
|
||||||
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
|
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
|
||||||
|
|
||||||
|
// Check if every document is validated in a folder
|
||||||
const documents = officeFolder.documents ?? [];
|
const documents = officeFolder.documents ?? [];
|
||||||
|
const documentsValidated = documents.filter((document) => {
|
||||||
|
let documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
|
||||||
|
return documentHydrated.document_status === "VALIDATED";
|
||||||
|
});
|
||||||
|
|
||||||
if (documents.length === 0) {
|
if (documentsValidated.length !== documents.length && documents.length !== 0) {
|
||||||
this.httpBadRequest(response, "OfficeFolder has no documents at all");
|
this.httpBadRequest(response, "Cannot anchor a folder with non validated documents");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasInvalidDocument = documents.some((document: any) => {
|
const folderHashes = getFolderHashes(officeFolder);
|
||||||
const documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
|
|
||||||
return documentHydrated.document_status !== "VALIDATED" &&
|
|
||||||
documentHydrated.document_status !== "REFUSED";
|
|
||||||
});
|
|
||||||
|
|
||||||
if (hasInvalidDocument) {
|
if (folderHashes.length === 0) {
|
||||||
this.httpBadRequest(response, "OfficeFolder has non validated documents");
|
this.httpNotFoundRequest(response, "No file hash to anchor");
|
||||||
return;
|
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const sortedHashes = [...folderHashes].sort();
|
const sortedHashes = [...folderHashes].sort();
|
||||||
const data = await this.secureService.anchor(sortedHashes);
|
const data = await this.secureService.anchor(sortedHashes);
|
||||||
|
|
||||||
@ -240,24 +230,7 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
|
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) {
|
if (folderHashes.length === 0) {
|
||||||
this.httpNotFoundRequest(response, "No file hash to anchor");
|
this.httpNotFoundRequest(response, "No file hash to anchor");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user