Improve message download performance

This commit is contained in:
Scott Nonnenberg
2019-09-26 12:56:31 -07:00
parent 957f6f6474
commit 0c09f9620f
32 changed files with 906 additions and 633 deletions

View File

@@ -35766,6 +35766,8 @@ Internal.SessionRecord = function() {
return SessionRecord;
}();
libsignal.SessionRecord = Internal.SessionRecord;
function SignalProtocolAddress(name, deviceId) {
this.name = name;
this.deviceId = deviceId;
@@ -35844,18 +35846,15 @@ SessionBuilder.prototype = {
});
}.bind(this)).then(function(session) {
var address = this.remoteAddress.toString();
return this.storage.loadSession(address).then(function(serialized) {
var record;
if (serialized !== undefined) {
record = Internal.SessionRecord.deserialize(serialized);
} else {
return this.storage.loadSession(address).then(function(record) {
if (record === undefined) {
record = new Internal.SessionRecord();
}
record.archiveCurrentState();
record.updateSessionState(session);
return Promise.all([
this.storage.storeSession(address, record.serialize()),
this.storage.storeSession(address, record),
this.storage.saveIdentity(this.remoteAddress.toString(), device.identityKey)
]);
}.bind(this));
@@ -36039,12 +36038,7 @@ function SessionCipher(storage, remoteAddress) {
SessionCipher.prototype = {
getRecord: function(encodedNumber) {
return this.storage.loadSession(encodedNumber).then(function(serialized) {
if (serialized === undefined) {
return undefined;
}
return Internal.SessionRecord.deserialize(serialized);
});
return this.storage.loadSession(encodedNumber);
},
// encoding is an optional parameter - wrap() will only translate if one is provided
encrypt: function(buffer, encoding) {
@@ -36124,7 +36118,7 @@ SessionCipher.prototype = {
return this.storage.saveIdentity(this.remoteAddress.toString(), theirIdentityKey);
}.bind(this)).then(function() {
record.updateSessionState(session);
return this.storage.storeSession(address, record.serialize()).then(function() {
return this.storage.storeSession(address, record).then(function() {
return result;
});
}.bind(this));
@@ -36211,7 +36205,7 @@ SessionCipher.prototype = {
return this.storage.saveIdentity(this.remoteAddress.toString(), result.session.indexInfo.remoteIdentityKey);
}.bind(this)).then(function() {
record.updateSessionState(result.session);
return this.storage.storeSession(address, record.serialize()).then(function() {
return this.storage.storeSession(address, record).then(function() {
return result.plaintext;
});
}.bind(this));
@@ -36246,7 +36240,7 @@ SessionCipher.prototype = {
preKeyProto.message.toArrayBuffer(), session
).then(function(plaintext) {
record.updateSessionState(session);
return this.storage.storeSession(address, record.serialize()).then(function() {
return this.storage.storeSession(address, record).then(function() {
if (preKeyId !== undefined && preKeyId !== null) {
return this.storage.removePreKey(preKeyId);
}
@@ -36444,7 +36438,7 @@ SessionCipher.prototype = {
}
record.archiveCurrentState();
return this.storage.storeSession(address, record.serialize());
return this.storage.storeSession(address, record);
}.bind(this));
}.bind(this));
},
@@ -36458,7 +36452,7 @@ SessionCipher.prototype = {
}
record.deleteAllSessions();
return this.storage.storeSession(address, record.serialize());
return this.storage.storeSession(address, record);
}.bind(this));
}.bind(this));
}