diff --git a/indexedDb/impl/channels/implementation.go b/indexedDb/impl/channels/implementation.go index 803331357caa122fe00aaca7c77c296e21d4e3df..703e4bb0f22fee52209bb5eb63818ca887910e24 100644 --- a/indexedDb/impl/channels/implementation.go +++ b/indexedDb/impl/channels/implementation.go @@ -12,6 +12,7 @@ package main import ( "crypto/ed25519" "encoding/json" + "strconv" "strings" "sync" "syscall/js" @@ -382,7 +383,7 @@ func buildMessage(channelID, messageID, parentID []byte, nickname string, ChannelID: channelID, ParentMessageID: parentID, Timestamp: timestamp, - Lease: lease, + Lease: strconv.FormatInt(int64(lease), 10), Status: uint8(status), Hidden: hidden, Pinned: pinned, @@ -466,6 +467,15 @@ func (w *wasmModel) GetMessage( } } + lease := time.Duration(0) + if len(lookupResult.Lease) > 0 { + leaseInt, err := strconv.ParseInt(lookupResult.Lease, 10, 64) + if err != nil { + return channels.ModelMessage{}, err + } + lease = time.Duration(leaseInt) + } + return channels.ModelMessage{ UUID: lookupResult.ID, Nickname: lookupResult.Nickname, @@ -473,7 +483,7 @@ func (w *wasmModel) GetMessage( ChannelID: channelId, ParentMessageID: parentMsgId, Timestamp: lookupResult.Timestamp, - Lease: lookupResult.Lease, + Lease: lease, Status: channels.SentStatus(lookupResult.Status), Hidden: lookupResult.Hidden, Pinned: lookupResult.Pinned, diff --git a/indexedDb/impl/channels/model.go b/indexedDb/impl/channels/model.go index d90d5d0ff932c922634cdc49276074173631aea1..5ea934d7c7ca64d5dad74c1ebafc9fff2427b9ab 100644 --- a/indexedDb/impl/channels/model.go +++ b/indexedDb/impl/channels/model.go @@ -45,19 +45,19 @@ const ( // The user's nickname can change each message, but the rest does not. We // still duplicate all of it for each entry to simplify code for now. type Message struct { - ID uint64 `json:"id"` // Matches pkeyName - Nickname string `json:"nickname"` - MessageID []byte `json:"message_id"` // Index - ChannelID []byte `json:"channel_id"` // Index - ParentMessageID []byte `json:"parent_message_id"` // Index - Timestamp time.Time `json:"timestamp"` // Index - Lease time.Duration `json:"lease"` - Status uint8 `json:"status"` - Hidden bool `json:"hidden"` - Pinned bool `json:"pinned"` // Index - Text []byte `json:"text"` - Type uint16 `json:"type"` - Round uint64 `json:"round"` + ID uint64 `json:"id"` // Matches pkeyName + Nickname string `json:"nickname"` + MessageID []byte `json:"message_id"` // Index + ChannelID []byte `json:"channel_id"` // Index + ParentMessageID []byte `json:"parent_message_id"` // Index + Timestamp time.Time `json:"timestamp"` // Index + Lease string `json:"lease_v2"` + Status uint8 `json:"status"` + Hidden bool `json:"hidden"` + Pinned bool `json:"pinned"` // Index + Text []byte `json:"text"` + Type uint16 `json:"type"` + Round uint64 `json:"round"` // User cryptographic Identity struct -- could be pulled out Pubkey []byte `json:"pubkey"`