From 85bad8dd766192f7ac2ed6fac45a5294462f4fad Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Wed, 15 Jan 2020 18:52:20 +0100
Subject: [PATCH] [fix] `search [pattern]` command: add exclusions display

---
 app/modules/dump.ts | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/modules/dump.ts b/app/modules/dump.ts
index 80ac4a310..21b85e8a3 100644
--- a/app/modules/dump.ts
+++ b/app/modules/dump.ts
@@ -164,7 +164,7 @@ module.exports = {
 
           const blocks = Underscore.sortBy(await findBlocksMatching(pattern, files), b => b.number)
 
-          const events: { b: BlockDTO, event: (IdentityDTO|ShortCertificationDTO|MembershipDTO|ShortRevocation) }[] = []
+          const events: { b: BlockDTO, event: (IdentityDTO|ShortCertificationDTO|MembershipDTO|ShortRevocation|{ type: 'exclusion', pub: string }) }[] = []
           for (const b of blocks) {
             b.identities.filter(i => i.includes(pattern)).forEach(i => {
               events.push({ b, event: IdentityDTO.fromInline(i) })
@@ -178,6 +178,9 @@ module.exports = {
             b.revoked.filter(m => m.includes(pattern)).forEach(r => {
               events.push({ b, event: RevocationDTO.fromInline(r) })
             })
+            b.excluded.filter(m => m.includes(pattern)).forEach(r => {
+              events.push({ b, event: { type: 'exclusion', pub: r } })
+            })
           }
 
           for (const e of events) {
@@ -186,6 +189,10 @@ module.exports = {
               const idty = e.event as IdentityDTO
               console.log('%s: new identity %s (created on %s)', date, idty.uid, await getDateFor(server, idty.buid as string))
             }
+            if ((e.event as { type: 'exclusion', pub: string }).type === 'exclusion') {
+              const date = await getDateForBlock(e.b)
+              console.log('%s: excluded', date)
+            }
           }
 
           console.log(events.map(e => e.event))
-- 
GitLab