Archive sessions on key changes after profile fetch

// FREEBIE
pull/749/head
lilia 8 years ago committed by Scott Nonnenberg
parent 4232f5711c
commit 3acfda3a56

@ -589,8 +589,12 @@
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey, 'base64').toArrayBuffer();
return textsecure.storage.protocol.saveIdentity(
id, identityKey, false
);
id, identityKey, false
).then(function(isIdentityChange) {
if (isIdentityChange) {
return textsecure.storage.protocol.archiveAllSessions(id);
}
});
});
},

@ -338,6 +338,16 @@
});
});
},
archiveAllSessions: function(number) {
return this.getDeviceIds(number).then(function(deviceIds) {
return Promise.all(deviceIds.map(function(deviceId) {
var address = new libsignal.SignalProtocolAddress(number, deviceId);
console.log('closing session for', address.toString());
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
return sessionCipher.closeOpenSessionForDevice();
}));
});
},
clearSessionStore: function() {
return new Promise(function(resolve) {
var sessions = new SessionCollection();

Loading…
Cancel
Save