Skip to content
Snippets Groups Projects

Also update conversation if we detect that the dmToken has changed.

1 file
+ 20
2
Compare changes
  • Side-by-side
  • Inline
+ 20
2
@@ -218,6 +218,8 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
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
result, err := w.getConversation(partnerKey)
if err != nil {
@@ -238,6 +240,7 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww.DEBUG.Printf(
"[DM indexedDB] Conversation with %s already joined", nickname)
updateConversation := false
// Update Conversation if nickname was altered
isFromPartner := bytes.Equal(result.Pubkey, senderKey)
nicknameChanged := result.Nickname != nickname
@@ -245,13 +248,28 @@ func (w *wasmModel) receiveWrapper(messageID message.ID, parentID *message.ID, n
jww.DEBUG.Printf(
"[DM indexedDB] Updating from nickname %s to %s",
result.Nickname, nickname)
err = w.upsertConversation(nickname, result.Pubkey, result.Token,
result.CodesetVersion, result.Blocked)
updateConversation = true
}
// Fix conversation if dmToken is altered
dmTokenChanged := result.Token != dmToken
if isFromPartner && dmTokenChanged {
jww.WARN.Printf(
"[DM indexedDB] Updating from dmToken %s to %s",
Please register or sign in to reply
result.Token, dmToken)
updateConversation = true
}
if updateConversation {
err = w.upsertConversation(nickname, result.Pubkey,
result.Token, result.CodesetVersion,
result.Blocked)
if err != nil {
return 0, err
}
conversationUpdated = true
    • I think you can remove this boolean now since you added a new one that functionally means the same thing

      • I can't because conversationUpdated can happen on line 235 as well, so I believe these 2 vars have different semantics. One is used to determine if the entry can be updated, the other is used to determine if it has.

        The code is due for a refactor, but thats a bit hairy and I am worried about correctness (I am sure it is correct now, I would not be sure if I made the changes necessary to remove conversationUpdated), so i'll add a FIXME.

      • It doesn't appear to be there are different semantics. You can move the upsert call in the first block down with all the others

      • Please register or sign in to reply
Please register or sign in to reply
}
}
// Handle encryption, if it is present
Loading