From 04d22756e4f15e27e8027faae4ccbfc0714c67ae Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 14 Nov 2017 18:38:31 +0100
Subject: [PATCH] [enh] Sandbox: keep `pubkey` + add `issuer` control

---
 app/lib/dal/sqliteDAL/DocumentDAL.ts | 4 +++-
 app/lib/dal/sqliteDAL/SandBox.ts     | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/lib/dal/sqliteDAL/DocumentDAL.ts b/app/lib/dal/sqliteDAL/DocumentDAL.ts
index d427e3e5f..a60aa335e 100644
--- a/app/lib/dal/sqliteDAL/DocumentDAL.ts
+++ b/app/lib/dal/sqliteDAL/DocumentDAL.ts
@@ -1,3 +1,5 @@
 export interface DBDocument {
-  issuers: string[];
+  pubkey?: string
+  issuer?: string
+  issuers?: string[]
 }
\ No newline at end of file
diff --git a/app/lib/dal/sqliteDAL/SandBox.ts b/app/lib/dal/sqliteDAL/SandBox.ts
index 8a0d3077d..85ae101c5 100644
--- a/app/lib/dal/sqliteDAL/SandBox.ts
+++ b/app/lib/dal/sqliteDAL/SandBox.ts
@@ -1,4 +1,4 @@
-import { DBDocument } from './DocumentDAL';
+import {DBDocument} from './DocumentDAL';
 
 export class SandBox<T extends DBDocument> {
 
@@ -13,7 +13,9 @@ export class SandBox<T extends DBDocument> {
   }
   
   async acceptNewSandBoxEntry(element:T, pubkey:string) {
-    if (element.issuers !== undefined && element.issuers.indexOf(pubkey) !== -1) {
+    if (element.pubkey === pubkey
+      || element.issuer === pubkey
+      || (element.issuers !== undefined && element.issuers.indexOf(pubkey) !== -1)) {
       return true;
     }
     const elements = await this.findElements()
-- 
GitLab