OutgoingMessage: On OutgoingKeyError, archive all sessions

* OutgoingMessage: On OutgoingKeyError, archive all sessions
* Improve logging
This commit is contained in:
Scott Nonnenberg 2020-01-10 08:10:43 -08:00 committed by Ken Powers
parent 1bf9ca7233
commit 14cc11d5de

View file

@ -413,11 +413,35 @@ OutgoingMessage.prototype = {
number,
deviceIds
);
throw error;
} else {
this.registerError(number, 'Failed to create or send message', error);
const address = new libsignal.SignalProtocolAddress(number, 1);
const identifier = address.toString();
window.log.info('closing all sessions for', number);
const sessionCipher = new libsignal.SessionCipher(
textsecure.storage.protocol,
address
);
window.log.info('closing session for', address.toString());
return Promise.all([
// Primary device
sessionCipher.closeOpenSessionForDevice(),
// The rest of their devices
textsecure.storage.protocol.archiveSiblingSessions(identifier),
]).then(
() => {
throw error;
},
innerError => {
window.log.error(
`doSendMessage: Error closing sessions: ${innerError.stack}`
);
throw error;
}
);
}
this.registerError(number, 'Failed to create or send message', error);
return null;
});
},