From bac90f003c47547b7720567b441dbb3f454ae086 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Wed, 30 Jul 2025 13:26:05 +0200 Subject: [PATCH] Conditional hydration of folder_anchor --- .../notary/OfficeFolderAnchorsController.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/api/notary/OfficeFolderAnchorsController.ts b/src/app/api/notary/OfficeFolderAnchorsController.ts index 1fa7e864..ff4bc9fe 100644 --- a/src/app/api/notary/OfficeFolderAnchorsController.ts +++ b/src/app/api/notary/OfficeFolderAnchorsController.ts @@ -170,16 +170,18 @@ export default class OfficeFoldersController extends ApiController { return; } - const officeFolderAnchorFound = OfficeFolderAnchor.hydrate(officeFolderFound.folder_anchor, { - strategy: "excludeAll", - }); - - if (officeFolderAnchorFound) { - this.httpBadRequest(response, { - error: "Office folder already anchored", - folder_anchor: officeFolderAnchorFound, + if (officeFolderFound.folder_anchor) { + const officeFolderAnchorFound = OfficeFolderAnchor.hydrate(officeFolderFound.folder_anchor, { + strategy: "excludeAll", }); - return; + + if (officeFolderAnchorFound) { + this.httpBadRequest(response, { + error: "Office folder already anchored", + folder_anchor: officeFolderAnchorFound, + }); + return; + } } const officeFolder = OfficeFolder.hydrate(officeFolderFound, { strategy: "excludeAll" });