Chat and message toString format

This commit is contained in:
Richard Ramos 2020-06-13 15:17:52 -04:00 committed by Iuri Matias
parent 0ca50b4e06
commit f46eed86d7
3 changed files with 11 additions and 2 deletions

View File

@ -90,7 +90,7 @@ proc toMessage*(jsonMsg: JsonNode): Message =
contentType: ContentType(jsonMsg{"contentType"}.getInt),
ensName: jsonMsg{"ensName"}.getStr,
fromAuthor: jsonMsg{"from"}.getStr,
id: jsonMsg{"identicon"}.getStr,
id: jsonMsg{"id"}.getStr,
identicon: jsonMsg{"identicon"}.getStr,
lineCount: jsonMsg{"lineCount"}.getInt,
localChatId: jsonMsg{"localChatId"}.getStr,

View File

@ -1,4 +1,5 @@
import message
import strformat
type ChatType* {.pure.}= enum
Unknown = 0,
@ -30,6 +31,9 @@ type Chat* = ref object
members*: seq[ChatMember]
# membershipUpdateEvents # ?
proc `$`*(self: Chat): string =
result = fmt"Chat(id:{self.id}, name:{self.name}, active:{self.isActive}, type:{self.chatType})"
proc findIndexById*(self: seq[Chat], id: string): int =
result = -1
var idx = -1

View File

@ -1,3 +1,5 @@
import strformat
type ContentType* {.pure.} = enum
ChatIdentifier = -1,
Unknown = 0,
@ -32,4 +34,7 @@ type Message* = object
timestamp*: string
whisperTimestamp*: string
isCurrentUser*: bool
stickerHash*: string
stickerHash*: string
proc `$`*(self: Message): string =
result = fmt"Message(id:{self.id}, chatId:{self.chatId}, clock:{self.clock}, from:{self.fromAuthor}, type:{self.contentType})"