Chat and message toString format
This commit is contained in:
parent
0ca50b4e06
commit
f46eed86d7
|
@ -90,7 +90,7 @@ proc toMessage*(jsonMsg: JsonNode): Message =
|
||||||
contentType: ContentType(jsonMsg{"contentType"}.getInt),
|
contentType: ContentType(jsonMsg{"contentType"}.getInt),
|
||||||
ensName: jsonMsg{"ensName"}.getStr,
|
ensName: jsonMsg{"ensName"}.getStr,
|
||||||
fromAuthor: jsonMsg{"from"}.getStr,
|
fromAuthor: jsonMsg{"from"}.getStr,
|
||||||
id: jsonMsg{"identicon"}.getStr,
|
id: jsonMsg{"id"}.getStr,
|
||||||
identicon: jsonMsg{"identicon"}.getStr,
|
identicon: jsonMsg{"identicon"}.getStr,
|
||||||
lineCount: jsonMsg{"lineCount"}.getInt,
|
lineCount: jsonMsg{"lineCount"}.getInt,
|
||||||
localChatId: jsonMsg{"localChatId"}.getStr,
|
localChatId: jsonMsg{"localChatId"}.getStr,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import message
|
import message
|
||||||
|
import strformat
|
||||||
|
|
||||||
type ChatType* {.pure.}= enum
|
type ChatType* {.pure.}= enum
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
@ -30,6 +31,9 @@ type Chat* = ref object
|
||||||
members*: seq[ChatMember]
|
members*: seq[ChatMember]
|
||||||
# membershipUpdateEvents # ?
|
# 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 =
|
proc findIndexById*(self: seq[Chat], id: string): int =
|
||||||
result = -1
|
result = -1
|
||||||
var idx = -1
|
var idx = -1
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import strformat
|
||||||
|
|
||||||
type ContentType* {.pure.} = enum
|
type ContentType* {.pure.} = enum
|
||||||
ChatIdentifier = -1,
|
ChatIdentifier = -1,
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
|
@ -33,3 +35,6 @@ type Message* = object
|
||||||
whisperTimestamp*: string
|
whisperTimestamp*: string
|
||||||
isCurrentUser*: bool
|
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})"
|
||||||
|
|
Loading…
Reference in New Issue