feat: mailserver request signals (#46)
This commit is contained in:
parent
38a405b1c1
commit
c07e04e976
|
@ -24,6 +24,9 @@ proc decode*(jsonSignal: JsonNode): Signal =
|
||||||
of SignalType.CommunityFound: CommunitySignal.fromEvent(jsonSignal)
|
of SignalType.CommunityFound: CommunitySignal.fromEvent(jsonSignal)
|
||||||
of SignalType.Stats: StatsSignal.fromEvent(jsonSignal)
|
of SignalType.Stats: StatsSignal.fromEvent(jsonSignal)
|
||||||
of SignalType.ChroniclesLogs: ChroniclesLogsSignal.fromEvent(jsonSignal)
|
of SignalType.ChroniclesLogs: ChroniclesLogsSignal.fromEvent(jsonSignal)
|
||||||
|
of SignalType.HistoryRequestCompleted: HistoryRequestCompletedSignal.fromEvent(jsonSignal)
|
||||||
|
of SignalType.HistoryRequestStarted: HistoryRequestStartedSignal.fromEvent(jsonSignal)
|
||||||
|
of SignalType.HistoryRequestFailed: HistoryRequestFailedSignal.fromEvent(jsonSignal)
|
||||||
else: Signal()
|
else: Signal()
|
||||||
|
|
||||||
result.signalType = signalType
|
result.signalType = signalType
|
||||||
|
|
|
@ -13,6 +13,13 @@ type MailserverRequestCompletedSignal* = ref object of Signal
|
||||||
type MailserverRequestExpiredSignal* = ref object of Signal
|
type MailserverRequestExpiredSignal* = ref object of Signal
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
type HistoryRequestStartedSignal* = ref object of Signal
|
||||||
|
type HistoryRequestCompletedSignal* = ref object of Signal
|
||||||
|
type HistoryRequestFailedSignal* = ref object of Signal
|
||||||
|
errorMessage*: string
|
||||||
|
error*: bool
|
||||||
|
|
||||||
|
|
||||||
proc fromEvent*(T: type MailserverRequestCompletedSignal, jsonSignal: JsonNode): MailserverRequestCompletedSignal =
|
proc fromEvent*(T: type MailserverRequestCompletedSignal, jsonSignal: JsonNode): MailserverRequestCompletedSignal =
|
||||||
result = MailserverRequestCompletedSignal()
|
result = MailserverRequestCompletedSignal()
|
||||||
result.signalType = SignalType.MailserverRequestCompleted
|
result.signalType = SignalType.MailserverRequestCompleted
|
||||||
|
@ -27,3 +34,18 @@ proc fromEvent*(T: type MailserverRequestExpiredSignal, jsonSignal: JsonNode): M
|
||||||
# TODO: parse signal
|
# TODO: parse signal
|
||||||
result = MailserverRequestExpiredSignal()
|
result = MailserverRequestExpiredSignal()
|
||||||
result.signalType = SignalType.MailserverRequestExpired
|
result.signalType = SignalType.MailserverRequestExpired
|
||||||
|
|
||||||
|
proc fromEvent*(T: type HistoryRequestStartedSignal, jsonSignal: JsonNode): HistoryRequestStartedSignal =
|
||||||
|
result = HistoryRequestStartedSignal()
|
||||||
|
result.signalType = SignalType.HistoryRequestStarted
|
||||||
|
|
||||||
|
proc fromEvent*(T: type HistoryRequestCompletedSignal, jsonSignal: JsonNode): HistoryRequestCompletedSignal =
|
||||||
|
result = HistoryRequestCompletedSignal()
|
||||||
|
result.signalType = SignalType.HistoryRequestCompleted
|
||||||
|
|
||||||
|
proc fromEvent*(T: type HistoryRequestFailedSignal, jsonSignal: JsonNode): HistoryRequestFailedSignal =
|
||||||
|
result = HistoryRequestFailedSignal()
|
||||||
|
result.signalType = SignalType.HistoryRequestStarted
|
||||||
|
if jsonSignal["event"].kind != JNull:
|
||||||
|
result.errorMessage = jsonSignal["event"]{"errorMessage"}.getStr()
|
||||||
|
result.error = result.errorMessage != ""
|
||||||
|
|
|
@ -21,6 +21,9 @@ type SignalType* {.pure.} = enum
|
||||||
CommunityFound = "community.found"
|
CommunityFound = "community.found"
|
||||||
Stats = "stats"
|
Stats = "stats"
|
||||||
ChroniclesLogs = "chronicles-log"
|
ChroniclesLogs = "chronicles-log"
|
||||||
|
HistoryRequestStarted = "history.request.started"
|
||||||
|
HistoryRequestCompleted = "history.request.completed"
|
||||||
|
HistoryRequestFailed = "history.request.failed"
|
||||||
Unknown
|
Unknown
|
||||||
|
|
||||||
proc event*(self:SignalType):string =
|
proc event*(self:SignalType):string =
|
||||||
|
|
Loading…
Reference in New Issue