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 type StatusUpdate* = object
publicKey*: string publicKey*: string
statusType*: StatusUpdateType statusType*: StatusUpdateType
clock*: int64 clock*: uint64
text*: string text*: string
type Community* = object type Community* = object

View File

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