feat: mailserver request signals
This commit is contained in:
parent
a9b06fde83
commit
dca94bd93a
|
@ -24,6 +24,9 @@ proc decode*(jsonSignal: JsonNode): Signal =
|
|||
of SignalType.CommunityFound: CommunitySignal.fromEvent(jsonSignal)
|
||||
of SignalType.Stats: StatsSignal.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()
|
||||
|
||||
result.signalType = signalType
|
||||
|
|
|
@ -13,6 +13,13 @@ type MailserverRequestCompletedSignal* = ref object of Signal
|
|||
type MailserverRequestExpiredSignal* = ref object of Signal
|
||||
# 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 =
|
||||
result = MailserverRequestCompletedSignal()
|
||||
result.signalType = SignalType.MailserverRequestCompleted
|
||||
|
@ -27,3 +34,18 @@ proc fromEvent*(T: type MailserverRequestExpiredSignal, jsonSignal: JsonNode): M
|
|||
# TODO: parse signal
|
||||
result = MailserverRequestExpiredSignal()
|
||||
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"
|
||||
Stats = "stats"
|
||||
ChroniclesLogs = "chronicles-log"
|
||||
HistoryRequestStarted = "history.request.started"
|
||||
HistoryRequestCompleted = "history.request.completed"
|
||||
HistoryRequestFailed = "history.request.failed"
|
||||
Unknown
|
||||
|
||||
proc event*(self:SignalType):string =
|
||||
|
|
Loading…
Reference in New Issue