Skip to content
Snippets Groups Projects
Commit c23af33e authored by Jake Taylor's avatar Jake Taylor :lips:
Browse files

fix formatting crash and DM EM impl bool logic

parent 1b968576
No related branches found
No related tags found
1 merge request!67fix for latest client release
...@@ -30,8 +30,7 @@ import ( ...@@ -30,8 +30,7 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
) )
// wasmModel implements dm.EventModel interface, which uses the channels system // wasmModel implements dm.EventModel interface backed by IndexedDb.
// passed an object that adheres to in order to get events on the channel.
// NOTE: This model is NOT thread safe - it is the responsibility of the // NOTE: This model is NOT thread safe - it is the responsibility of the
// caller to ensure that its methods are called sequentially. // caller to ensure that its methods are called sequentially.
type wasmModel struct { type wasmModel struct {
...@@ -217,9 +216,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -217,9 +216,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
data string, partnerKey, senderKey ed25519.PublicKey, dmToken uint32, codeset uint8, data string, partnerKey, senderKey ed25519.PublicKey, dmToken uint32, codeset uint8,
timestamp time.Time, round rounds.Round, mType dm.MessageType, status dm.Status) (uint64, error) { timestamp time.Time, round rounds.Round, mType dm.MessageType, status dm.Status) (uint64, error) {
// Keep track of whether Conversation was altered
// FIXME: this is very similar to updateConversation
//. below. Can we merge them?
conversationUpdated := false conversationUpdated := false
result, err := w.getConversation(partnerKey) result, err := w.getConversation(partnerKey)
if err != nil { if err != nil {
...@@ -240,7 +236,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -240,7 +236,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww.DEBUG.Printf( jww.DEBUG.Printf(
"[DM indexedDB] Conversation with %s already joined", nickname) "[DM indexedDB] Conversation with %s already joined", nickname)
updateConversation := false
// Update Conversation if nickname was altered // Update Conversation if nickname was altered
isFromPartner := bytes.Equal(result.Pubkey, senderKey) isFromPartner := bytes.Equal(result.Pubkey, senderKey)
nicknameChanged := result.Nickname != nickname nicknameChanged := result.Nickname != nickname
...@@ -248,19 +243,21 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -248,19 +243,21 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww.DEBUG.Printf( jww.DEBUG.Printf(
"[DM indexedDB] Updating from nickname %s to %s", "[DM indexedDB] Updating from nickname %s to %s",
result.Nickname, nickname) result.Nickname, nickname)
updateConversation = true conversationUpdated = true
} }
// Fix conversation if dmToken is altered // Fix conversation if dmToken is altered
dmTokenChanged := result.Token != dmToken dmTokenChanged := result.Token != dmToken
if isFromPartner && dmTokenChanged { if isFromPartner && dmTokenChanged {
jww.WARN.Printf( jww.WARN.Printf(
"[DM indexedDB] Updating from dmToken %s to %s", "[DM indexedDB] Updating from dmToken %d to %d",
result.Token, dmToken) result.Token, dmToken)
updateConversation = true conversationUpdated = true
}
} }
if updateConversation { // Update the conversation in storage, if needed
if conversationUpdated {
err = w.upsertConversation(nickname, result.Pubkey, err = w.upsertConversation(nickname, result.Pubkey,
result.Token, result.CodesetVersion, result.Token, result.CodesetVersion,
result.Blocked) result.Blocked)
...@@ -270,8 +267,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -270,8 +267,6 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
conversationUpdated = true conversationUpdated = true
} }
}
// Handle encryption, if it is present // Handle encryption, if it is present
textBytes := []byte(data) textBytes := []byte(data)
if w.cipher != nil { if w.cipher != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment