Skip to content
Snippets Groups Projects
Commit 1e676b12 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Make it clear we are working with a partnerToken and fix bug where we updated...

Make it clear we are working with a partnerToken and fix bug where we updated a conversation to the senderKey and not the partnerKey
parent b7ec3c50
No related branches found
No related tags found
2 merge requests!99Make it clear we are working with a partnerToken and fix bug where we updated...,!67fix for latest client release
...@@ -41,14 +41,15 @@ type wasmModel struct { ...@@ -41,14 +41,15 @@ type wasmModel struct {
// upsertConversation is used for joining or updating a Conversation. // upsertConversation is used for joining or updating a Conversation.
func (w *wasmModel) upsertConversation(nickname string, func (w *wasmModel) upsertConversation(nickname string,
pubKey ed25519.PublicKey, dmToken uint32, codeset uint8, blocked bool) error { pubKey ed25519.PublicKey, partnerToken uint32, codeset uint8,
blocked bool) error {
parentErr := errors.New("[DM indexedDB] failed to upsertConversation") parentErr := errors.New("[DM indexedDB] failed to upsertConversation")
// Build object // Build object
newConvo := Conversation{ newConvo := Conversation{
Pubkey: pubKey, Pubkey: pubKey,
Nickname: nickname, Nickname: nickname,
Token: dmToken, Token: partnerToken,
CodesetVersion: codeset, CodesetVersion: codeset,
Blocked: blocked, Blocked: blocked,
} }
...@@ -213,7 +214,7 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, messageID message.ID, ...@@ -213,7 +214,7 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, messageID message.ID,
// receiveWrapper is a higher-level wrapper of upsertMessage. // receiveWrapper is a higher-level wrapper of upsertMessage.
func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, nickname, func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, nickname,
data string, partnerKey, senderKey ed25519.PublicKey, dmToken uint32, codeset uint8, data string, partnerKey, senderKey ed25519.PublicKey, partnerToken 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 a Conversation was altered // Keep track of whether a Conversation was altered
...@@ -228,10 +229,11 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -228,10 +229,11 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
// If there is no extant Conversation, create one. // If there is no extant Conversation, create one.
jww.DEBUG.Printf( jww.DEBUG.Printf(
"[DM indexedDB] Joining conversation with %s", nickname) "[DM indexedDB] Joining conversation with %s", nickname)
convoToUpdate = &Conversation{ convoToUpdate = &Conversation{
Pubkey: senderKey, Pubkey: partnerKey,
Nickname: nickname, Nickname: nickname,
Token: dmToken, Token: partnerToken,
CodesetVersion: codeset, CodesetVersion: codeset,
Blocked: false, Blocked: false,
} }
...@@ -252,13 +254,13 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -252,13 +254,13 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
} }
// Fix conversation if dmToken is altered // Fix conversation if dmToken is altered
dmTokenChanged := result.Token != dmToken dmTokenChanged := result.Token != partnerToken
if isFromPartner && dmTokenChanged { if isFromPartner && dmTokenChanged {
jww.WARN.Printf( jww.WARN.Printf(
"[DM indexedDB] Updating from dmToken %d to %d", "[DM indexedDB] Updating from dmToken %d to %d",
result.Token, dmToken) result.Token, partnerToken)
convoToUpdate = result convoToUpdate = result
convoToUpdate.Token = dmToken convoToUpdate.Token = partnerToken
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment