Set messageKeysLimit to unlimited if communicating with our devices (#1348)

Set messageKeysLimit to unlimited if communicating with our devices

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-08-04 12:25:30 -07:00 committed by GitHub
parent 7e0bd82bd3
commit e223db56d9
4 changed files with 88 additions and 14 deletions

View file

@ -325,7 +325,17 @@ MessageReceiver.prototype.extend({
decrypt: function(envelope, ciphertext) {
var promise;
var address = new libsignal.SignalProtocolAddress(envelope.source, envelope.sourceDevice);
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
var ourNumber = textsecure.storage.user.getNumber();
var number = address.toString().split('.')[0];
var options = {};
// No limit on message keys if we're communicating with our other devices
if (ourNumber === number) {
options.messageKeysLimit = false;
}
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address, options);
switch(envelope.type) {
case textsecure.protobuf.Envelope.Type.CIPHERTEXT:
console.log('message from', this.getEnvelopeId(envelope));
@ -635,7 +645,17 @@ MessageReceiver.prototype.extend({
},
tryMessageAgain: function(from, ciphertext) {
var address = libsignal.SignalProtocolAddress.fromString(from);
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address);
var ourNumber = textsecure.storage.user.getNumber();
var number = address.toString().split('.')[0];
var options = {};
// No limit on message keys if we're communicating with our other devices
if (ourNumber === number) {
options.messageKeysLimit = false;
}
var sessionCipher = new libsignal.SessionCipher(textsecure.storage.protocol, address, options);
console.log('retrying prekey whisper message');
return this.decryptPreKeyWhisperMessage(ciphertext, sessionCipher, address).then(function(plaintext) {
var finalMessage = textsecure.protobuf.DataMessage.decode(plaintext);