From 3b2406ae73d535a8c1cfb57a7c3cc662cc6bcadc Mon Sep 17 00:00:00 2001
From: Benoit Lavenier <benoit.lavenier@e-is.pro>
Date: Wed, 31 May 2023 14:19:25 +0200
Subject: [PATCH] fix(1441): Add config's storage into BMA /node/summary -
 close #1441

---
 app/modules/bma/lib/controllers/node.ts  | 6 ++++++
 app/modules/bma/lib/dtos.ts              | 8 ++++++++
 doc/HTTP_API.md                          | 8 ++++++--
 test/fast/modules/bma/bma-module-test.ts | 2 ++
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/app/modules/bma/lib/controllers/node.ts b/app/modules/bma/lib/controllers/node.ts
index a2edfedaa..2bd24394f 100644
--- a/app/modules/bma/lib/controllers/node.ts
+++ b/app/modules/bma/lib/controllers/node.ts
@@ -22,6 +22,12 @@ export class NodeBinding extends AbstractController {
         software: "duniter",
         version: this.server.version,
         forkWindowSize: this.server.conf.forksize,
+        storage: {
+          transactions: this.server.conf.storage
+            ? this.server.conf.storage.transactions
+            : true, // true by default (see app/module/config.ts)
+          wotwizard: this.server.conf.storage?.wotwizard || false, // false by default (see app/module/config.ts)
+        },
       },
     };
   };
diff --git a/app/modules/bma/lib/dtos.ts b/app/modules/bma/lib/dtos.ts
index ee187a77e..d8ed12186 100644
--- a/app/modules/bma/lib/dtos.ts
+++ b/app/modules/bma/lib/dtos.ts
@@ -21,6 +21,10 @@ export const Summary = {
     software: String,
     version: String,
     forkWindowSize: Number,
+    storage: {
+      transactions: Boolean,
+      wotwizard: Boolean,
+    },
   },
 };
 
@@ -29,6 +33,10 @@ export interface HttpSummary {
     software: string;
     version: string;
     forkWindowSize: number;
+    storage: {
+      transactions: boolean;
+      wotwizard: boolean;
+    };
   };
 }
 
diff --git a/doc/HTTP_API.md b/doc/HTTP_API.md
index 3a5bace82..e3f91fa08 100644
--- a/doc/HTTP_API.md
+++ b/doc/HTTP_API.md
@@ -244,8 +244,12 @@ Technical informations about the node.
 {
   "duniter": {
     "software": "duniter",
-    "version": "0.10.3",
-    "forkWindowSize": 10
+    "version": "1.8.7",
+    "forkWindowSize": 100,
+    "storage": {
+      "transaction": true,
+      "wotwizard": false
+    }
   }
 }
 ```
diff --git a/test/fast/modules/bma/bma-module-test.ts b/test/fast/modules/bma/bma-module-test.ts
index 58c20ea81..cbec2c94a 100644
--- a/test/fast/modules/bma/bma-module-test.ts
+++ b/test/fast/modules/bma/bma-module-test.ts
@@ -51,6 +51,8 @@ describe('Module usage', () => {
     });
     should.exist(json);
     json.should.have.property('duniter').property('software').equal('duniter');
+    json.should.have.property('duniter').property('storage').property('transactions').equal(true);
+    json.should.have.property('duniter').property('storage').property('wotwizard').equal(false);
   })
 
   it('remoteipv4 should NOT be filled if remote Host is declared', async () => {
-- 
GitLab