feat: adding HistoryRequestBatchProcessed signal and batch attributes (#78)

* feat: adding HistoryRequestBatchProcessed signal and batch attributes

* bump status-go

Co-authored-by: Iuri Matias <iuri.matias@gmail.com>
This commit is contained in:
Richard Ramos 2021-11-09 17:19:29 -04:00 committed by GitHub
parent 7095b80cb6
commit 1aba03aed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 3 deletions

View File

@ -28,6 +28,7 @@ proc decode*(jsonSignal: JsonNode): Signal =
of SignalType.HistoryRequestCompleted: HistoryRequestCompletedSignal.fromEvent(jsonSignal) of SignalType.HistoryRequestCompleted: HistoryRequestCompletedSignal.fromEvent(jsonSignal)
of SignalType.HistoryRequestStarted: HistoryRequestStartedSignal.fromEvent(jsonSignal) of SignalType.HistoryRequestStarted: HistoryRequestStartedSignal.fromEvent(jsonSignal)
of SignalType.HistoryRequestFailed: HistoryRequestFailedSignal.fromEvent(jsonSignal) of SignalType.HistoryRequestFailed: HistoryRequestFailedSignal.fromEvent(jsonSignal)
of SignalType.HistoryRequestBatchProcessed: HistoryRequestBatchProcessedSignal.fromEvent(jsonSignal)
of SignalType.KeycardConnected: KeycardConnectedSignal.fromEvent(jsonSignal) of SignalType.KeycardConnected: KeycardConnectedSignal.fromEvent(jsonSignal)
else: Signal() else: Signal()

View File

@ -14,12 +14,22 @@ type MailserverRequestExpiredSignal* = ref object of Signal
# TODO # TODO
type HistoryRequestStartedSignal* = ref object of Signal type HistoryRequestStartedSignal* = ref object of Signal
requestId*: string
numBatches*: int
type HistoryRequestBatchProcessedSignal* = ref object of Signal
requestId*: string
batchIndex*: int
numBatches*: int
type HistoryRequestCompletedSignal* = ref object of Signal type HistoryRequestCompletedSignal* = ref object of Signal
requestId*: string
type HistoryRequestFailedSignal* = ref object of Signal type HistoryRequestFailedSignal* = ref object of Signal
requestId*: string
errorMessage*: string errorMessage*: string
error*: bool 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
@ -38,14 +48,25 @@ proc fromEvent*(T: type MailserverRequestExpiredSignal, jsonSignal: JsonNode): M
proc fromEvent*(T: type HistoryRequestStartedSignal, jsonSignal: JsonNode): HistoryRequestStartedSignal = proc fromEvent*(T: type HistoryRequestStartedSignal, jsonSignal: JsonNode): HistoryRequestStartedSignal =
result = HistoryRequestStartedSignal() result = HistoryRequestStartedSignal()
result.signalType = SignalType.HistoryRequestStarted result.signalType = SignalType.HistoryRequestStarted
result.requestId = jsonSignal["event"]{"requestId"}.getStr()
result.numBatches = jsonSIgnal["event"]{"numBatches"}.getInt()
proc fromEvent*(T: type HistoryRequestBatchProcessedSignal, jsonSignal: JsonNode): HistoryRequestBatchProcessedSignal =
result = HistoryRequestBatchProcessedSignal()
result.signalType = SignalType.HistoryRequestBatchProcessed
result.requestId = jsonSignal["event"]{"requestId"}.getStr()
result.batchIndex = jsonSIgnal["event"]{"batchIndex"}.getInt()
result.numBatches = jsonSIgnal["event"]{"numBatches"}.getInt()
proc fromEvent*(T: type HistoryRequestCompletedSignal, jsonSignal: JsonNode): HistoryRequestCompletedSignal = proc fromEvent*(T: type HistoryRequestCompletedSignal, jsonSignal: JsonNode): HistoryRequestCompletedSignal =
result = HistoryRequestCompletedSignal() result = HistoryRequestCompletedSignal()
result.signalType = SignalType.HistoryRequestCompleted result.signalType = SignalType.HistoryRequestCompleted
result.requestId = jsonSignal["event"]{"requestId"}.getStr()
proc fromEvent*(T: type HistoryRequestFailedSignal, jsonSignal: JsonNode): HistoryRequestFailedSignal = proc fromEvent*(T: type HistoryRequestFailedSignal, jsonSignal: JsonNode): HistoryRequestFailedSignal =
result = HistoryRequestFailedSignal() result = HistoryRequestFailedSignal()
result.signalType = SignalType.HistoryRequestStarted result.signalType = SignalType.HistoryRequestStarted
result.requestId = jsonSignal["event"]{"requestId"}.getStr()
if jsonSignal["event"].kind != JNull: if jsonSignal["event"].kind != JNull:
result.errorMessage = jsonSignal["event"]{"errorMessage"}.getStr() result.errorMessage = jsonSignal["event"]{"errorMessage"}.getStr()
result.error = result.errorMessage != "" result.error = result.errorMessage != ""

View File

@ -25,6 +25,7 @@ type SignalType* {.pure.} = enum
HistoryRequestStarted = "history.request.started" HistoryRequestStarted = "history.request.started"
HistoryRequestCompleted = "history.request.completed" HistoryRequestCompleted = "history.request.completed"
HistoryRequestFailed = "history.request.failed" HistoryRequestFailed = "history.request.failed"
HistoryRequestBatchProcessed = "history.request.batch.processed"
KeycardConnected = "keycard.connected" KeycardConnected = "keycard.connected"
Unknown Unknown

View File

@ -25,7 +25,7 @@ proc delete*(peer: string) =
proc requestAllHistoricMessages*(): string = proc requestAllHistoricMessages*(): string =
result = callPrivateRPC("requestAllHistoricMessages".prefix, %*[]) result = callPrivateRPC("requestAllHistoricMessages".prefix, %*[])
info "requestAllHistoricMessages", topics="mailserver-interaction", rpc_method="mailservers_requestAllHistoricMessages", result info "requestAllHistoricMessages", topics="mailserver-interaction", rpc_method="mailservers_requestAllHistoricMessages"
proc requestStoreMessages*(topics: seq[string], symKeyID: string, peer: string, numberOfMessages: int, fromTimestamp: int64 = 0, toTimestamp: int64 = 0, force: bool = false) = proc requestStoreMessages*(topics: seq[string], symKeyID: string, peer: string, numberOfMessages: int, fromTimestamp: int64 = 0, toTimestamp: int64 = 0, force: bool = false) =
var toValue = times.toUnix(times.getTime()) var toValue = times.toUnix(times.getTime())

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit d35e0a339ddfdee0e52e2f6d5859302c7ec54dc6 Subproject commit 7440c184c0e8fbb3ad88803ae66c87a9c32bf962