Ensure all sessions are archived on profile fetch
If the key has changed, saveIdentity will archive sibling sessions, but not the session for the device it was called on. Therefore we have to archive that one by hand. Also switch from saving the identity of an OutgoingIdentityKeyError to just triggering a profile fetch, mostly for consistency, simplicity, and DRYness. // FREEBIE
This commit is contained in:
parent
3206536d47
commit
aa83bc1dab
2 changed files with 17 additions and 10 deletions
|
@ -583,8 +583,17 @@
|
|||
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey, 'base64').toArrayBuffer();
|
||||
|
||||
return textsecure.storage.protocol.saveIdentity(
|
||||
id, identityKey, false
|
||||
);
|
||||
id + '.1', identityKey, false
|
||||
).then(function(changed) {
|
||||
if (changed) {
|
||||
// save identity will close all sessions except for .1, so we
|
||||
// must close that one manually.
|
||||
var address = new libsignal.SignalProtocolAddress(id, 1);
|
||||
console.log('closing session for', address.toString());
|
||||
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
|
||||
return sessionCipher.closeOpenSessionForDevice();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -225,10 +225,9 @@
|
|||
if (result.name === 'SignedPreKeyRotationError') {
|
||||
promises.push(getAccountManager().rotateSignedPreKey());
|
||||
}
|
||||
else if (result.name === 'OutgoingIdentityKeyError' && result.identityKey) {
|
||||
promises.push(textsecure.storage.protocol.saveIdentity(
|
||||
result.number, result.identityKey, false
|
||||
));
|
||||
else if (result.name === 'OutgoingIdentityKeyError') {
|
||||
var c = ConversationController.get(result.number);
|
||||
promises.push(c.getProfiles());
|
||||
}
|
||||
} else {
|
||||
this.saveErrors(result.errors);
|
||||
|
@ -237,10 +236,9 @@
|
|||
promises.push(this.sendSyncMessage());
|
||||
}
|
||||
promises = promises.concat(_.map(result.errors, function(error) {
|
||||
if (error.name === 'OutgoingIdentityKeyError' && error.identityKey) {
|
||||
return textsecure.storage.protocol.saveIdentity(
|
||||
error.number, error.identityKey, false
|
||||
);
|
||||
if (error.name === 'OutgoingIdentityKeyError') {
|
||||
var c = ConversationController.get(error.number);
|
||||
promises.push(c.getProfiles());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue