From 56571f6bdcd44651657a2c7bf037f574055d810a Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Fri, 23 Sep 2022 21:00:21 +0000 Subject: [PATCH] Update model to include User's cryptographic Identity and link it to the Messages table --- indexedDb/model.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/indexedDb/model.go b/indexedDb/model.go index c46bad40..6b26e908 100644 --- a/indexedDb/model.go +++ b/indexedDb/model.go @@ -20,15 +20,21 @@ const ( // Text representation of the names of the various [idb.ObjectStore]. messageStoreName = "messages" channelsStoreName = "channels" + userStoreName = "users" // Message index names. messageStoreChannelIndex = "channel_id_index" + messageStoreUserIndex = "user_id_index" messageStoreParentIndex = "parent_message_id_index" messageStoreTimestampIndex = "timestamp_index" messageStorePinnedIndex = "pinned_index" + // UserIdentity index names. + userStorePubkeyIndex = "pubkey_index" + // Message keyPath names (must match json struct tags). messageStoreChannel = "channel_id" + messageStoreUser = "user_id" messageStoreParent = "parent_message_id" messageStoreTimestamp = "timestamp" messageStorePinned = "pinned" @@ -39,10 +45,14 @@ const ( // A Message belongs to one Channel. // // A Message may belong to one Message (Parent). +// +// A Message belongs to one User (cryptographic identity). +// The user's nickname can change each message. type Message struct { Id []byte `json:"id"` // Matches pkeyName - SenderUsername string `json:"sender_username"` + Nickname string `json:"nickname"` ChannelId []byte `json:"channel_id"` // Index + UserId []byte `json:"user_id"` // Index ParentMessageId []byte `json:"parent_message_id"` // Index Timestamp time.Time `json:"timestamp"` // Index Lease time.Duration `json:"lease"` @@ -60,3 +70,19 @@ type Channel struct { Name string `json:"name"` Description string `json:"description"` } + +// User defines the IndexedDb representation of a single user's +// cryptographic identity +// +// A User has many Message. +type User struct { + Id []byte `json:"id"` // Matches pkeyName + Pubkey []byte `json:"pubkey"` //Index + Honorific string `json:"honorific"` + Adjective string `json:"adjective"` + Noun string `json:"noun"` + Codename string `json:"codename"` + Color string `json:"color"` + Extension string `json:"extension"` + CodesetVersion uint8 `json:"codeset_version"` +} -- GitLab