From 99b85d206381ac1654f4099d91c75640c5613c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rich=CE=9Brd?= Date: Wed, 15 Sep 2021 15:45:17 -0400 Subject: [PATCH] feat: trigger a signal for chronicles logs (#31) --- status/signals.nim | 5 +++-- status/signals/chronicles_logs.nim | 12 ++++++++++++ status/signals/signal_type.nim | 1 + vendor/nim-chronicles | 2 +- vendor/nim-json-serialization | 2 +- vendor/nim-serialization | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 status/signals/chronicles_logs.nim diff --git a/status/signals.nim b/status/signals.nim index f29bdf1..4d07aec 100644 --- a/status/signals.nim +++ b/status/signals.nim @@ -1,7 +1,7 @@ import json, json_serialization, strutils -import signals/[base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter] +import signals/[base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter] -export base, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter +export base, chronicles_logs, community, discovery_summary, envelope, expired, mailserver, messages, signal_type, stats, wallet, whisper_filter proc decode*(jsonSignal: JsonNode): Signal = let signalString = jsonSignal{"type"}.getStr @@ -23,4 +23,5 @@ proc decode*(jsonSignal: JsonNode): Signal = of SignalType.MailserverRequestExpired: MailserverRequestExpiredSignal.fromEvent(jsonSignal) of SignalType.CommunityFound: CommunitySignal.fromEvent(jsonSignal) of SignalType.Stats: StatsSignal.fromEvent(jsonSignal) + of SignalType.ChroniclesLogs: ChroniclesLogsSignal.fromEvent(jsonSignal) else: Signal() diff --git a/status/signals/chronicles_logs.nim b/status/signals/chronicles_logs.nim new file mode 100644 index 0000000..22d718e --- /dev/null +++ b/status/signals/chronicles_logs.nim @@ -0,0 +1,12 @@ +import json +import base +import signal_type + +type ChroniclesLogsSignal* = ref object of Signal + content*: string + +proc fromEvent*(T: type ChroniclesLogsSignal, jsonSignal: JsonNode): ChroniclesLogsSignal = + result = ChroniclesLogsSignal() + result.signalType = SignalType.ChroniclesLogs + if jsonSignal["event"].kind != JNull: + result.content = jsonSignal["event"].getStr() diff --git a/status/signals/signal_type.nim b/status/signals/signal_type.nim index 0a48eac..d3057c8 100644 --- a/status/signals/signal_type.nim +++ b/status/signals/signal_type.nim @@ -20,6 +20,7 @@ type SignalType* {.pure.} = enum WhisperFilterAdded = "whisper.filter.added" CommunityFound = "community.found" Stats = "stats" + ChroniclesLogs = "chronicles-log" Unknown proc event*(self:SignalType):string = diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles index fc3f2d3..ea0368c 160000 --- a/vendor/nim-chronicles +++ b/vendor/nim-chronicles @@ -1 +1 @@ -Subproject commit fc3f2d3755e035387ebcf20d87a45eb9dcefadbb +Subproject commit ea0368cc303b6ed59792a7c2556285adf310e455 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization index 1dccd4b..fe8a82c 160000 --- a/vendor/nim-json-serialization +++ b/vendor/nim-json-serialization @@ -1 +1 @@ -Subproject commit 1dccd4b2ef14c5e3ce30ad3f3a0962e0b98da6a3 +Subproject commit fe8a82ca76150b60a950d5aa4e5baa382441ada4 diff --git a/vendor/nim-serialization b/vendor/nim-serialization index 474bdbf..f9a1121 160000 --- a/vendor/nim-serialization +++ b/vendor/nim-serialization @@ -1 +1 @@ -Subproject commit 474bdbf49cf1634ba504888ad1a1927a2703bd3f +Subproject commit f9a1121b8733eb75e624ab59f8d79e707f15f76f