fix: code review

This commit is contained in:
Richard Ramos 2021-07-19 11:31:00 -04:00 committed by Iuri Matias
parent 07c399530b
commit b7747104ec
2 changed files with 4 additions and 4 deletions

View File

@ -115,7 +115,7 @@ type StatusUpdateType* {.pure.}= enum
type StatusUpdate* = object
publicKey*: string
statusType*: StatusUpdateType
clock*: int64
clock*: uint64
text*: string
type Community* = object

View File

@ -204,12 +204,12 @@ proc toChat*(jsonChat: JsonNode): Chat =
result.membershipUpdateEvents.add(jsonMember.toChatMembershipEvent)
proc toStatusUpdate*(jsonStatusUpdate: JsonNode): StatusUpdate =
let statusTypeInt = jsonStatusUpdate{"status-type"}.getInt
let statusTypeInt = jsonStatusUpdate{"statusType"}.getInt
let statusType: StatusUpdateType = if statusTypeInt >= ord(low(StatusUpdateType)) or statusTypeInt <= ord(high(StatusUpdateType)): StatusUpdateType(statusTypeInt) else: StatusUpdateType.Unknown
result = StatusUpdate(
publicKey: jsonStatusUpdate{"public-key"}.getStr,
publicKey: jsonStatusUpdate{"publicKey"}.getStr,
statusType: statusType,
clock: jsonStatusUpdate{"clock"}.getBiggestInt,
clock: uint64(jsonStatusUpdate{"clock"}.getBiggestInt),
text: jsonStatusUpdate{"text"}.getStr
)