Skip to content
Snippets Groups Projects
Commit 59b98750 authored by Jake Taylor's avatar Jake Taylor
Browse files

DM nickname will not update if message is from partner

parent cc80200f
No related branches found
No related tags found
1 merge request!67fix for latest client release
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
package main package main
import ( import (
"bytes"
"crypto/ed25519" "crypto/ed25519"
"encoding/json" "encoding/json"
"strings" "strings"
...@@ -42,7 +43,7 @@ type wasmModel struct { ...@@ -42,7 +43,7 @@ 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, dmToken uint32, codeset uint8, blocked bool) error {
parentErr := errors.New("failed to upsertConversation") parentErr := errors.New("[DM indexedDB] failed to upsertConversation")
// Build object // Build object
newConvo := Conversation{ newConvo := Conversation{
...@@ -231,6 +232,8 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -231,6 +232,8 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
return 0, err return 0, err
} else { } else {
// If there is no extant Conversation, create one. // If there is no extant Conversation, create one.
jww.DEBUG.Printf(
"[DM indexedDB] Joining conversation with %s", nickname)
err = w.upsertConversation(nickname, partnerKey, dmToken, err = w.upsertConversation(nickname, partnerKey, dmToken,
codeset, false) codeset, false)
if err != nil { if err != nil {
...@@ -243,7 +246,12 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n ...@@ -243,7 +246,12 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
"[DM indexedDB] Conversation with %s already joined", nickname) "[DM indexedDB] Conversation with %s already joined", nickname)
// Update Conversation if nickname was altered // Update Conversation if nickname was altered
if result.Nickname != nickname { isFromPartner := bytes.Equal(result.Pubkey, senderKey)
nicknameChanged := result.Nickname != nickname
if isFromPartner && nicknameChanged {
jww.DEBUG.Printf(
"[DM indexedDB] Updating from nickname %s to %s",
result.Nickname, nickname)
err = w.upsertConversation(nickname, result.Pubkey, result.Token, err = w.upsertConversation(nickname, result.Pubkey, result.Token,
result.CodesetVersion, result.Blocked) result.CodesetVersion, result.Blocked)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment