Handle exceptions when fetching keys for devices
It's rare that we get in a state where we have a device record without a session, but we should handle errors gracefully in that case. Catch them and register them, except for identity key errors which are registered in handleResult. // FREEBIE fixup error handling // FREEBIE
This commit is contained in:
parent
12276e691b
commit
01e85b68ef
2 changed files with 20 additions and 4 deletions
|
@ -39745,8 +39745,16 @@ OutgoingMessage.prototype = {
|
|||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
||||
return Promise.all(devicesForNumber.map(function(device) {
|
||||
return textsecure.protocol_wrapper.hasOpenSession(device.encodedNumber).then(function(result) {
|
||||
if (!result)
|
||||
return this.getKeysForNumber(number, [parseInt(textsecure.utils.unencodeNumber(device.encodedNumber)[1])]);
|
||||
if (!result) {
|
||||
return this.getKeysForNumber(number,
|
||||
[parseInt(textsecure.utils.unencodeNumber(device.encodedNumber)[1])]
|
||||
).catch(function(error) {
|
||||
if (error.name !== 'OutgoingIdentityKeyError') {
|
||||
this.registerError(number, "Failed to retreive new device keys for " + device.encodedNumber, error);
|
||||
}
|
||||
return Promise.reject();
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this))).then(function() {
|
||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
||||
|
|
|
@ -114,8 +114,16 @@ OutgoingMessage.prototype = {
|
|||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
||||
return Promise.all(devicesForNumber.map(function(device) {
|
||||
return textsecure.protocol_wrapper.hasOpenSession(device.encodedNumber).then(function(result) {
|
||||
if (!result)
|
||||
return this.getKeysForNumber(number, [parseInt(textsecure.utils.unencodeNumber(device.encodedNumber)[1])]);
|
||||
if (!result) {
|
||||
return this.getKeysForNumber(number,
|
||||
[parseInt(textsecure.utils.unencodeNumber(device.encodedNumber)[1])]
|
||||
).catch(function(error) {
|
||||
if (error.name !== 'OutgoingIdentityKeyError') {
|
||||
this.registerError(number, "Failed to retreive new device keys for " + device.encodedNumber, error);
|
||||
}
|
||||
return Promise.reject();
|
||||
}.bind(this));
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this))).then(function() {
|
||||
return textsecure.storage.devices.getDeviceObjectsForNumber(number).then(function(devicesForNumber) {
|
||||
|
|
Loading…
Reference in a new issue