diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 5895e0f5..5a357521 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38570,7 +38570,13 @@ OutgoingMessage.prototype = { var promise = Promise.resolve(); updateDevices.forEach(function(device) { promise = promise.then(function() { - return this.server.getKeysForNumber(number, device).then(handleResult); + return this.server.getKeysForNumber(number, device).then(handleResult).catch(function(e) { + if (e.name === 'HTTPError' && e.code === 404 && device !== 1) { + return this.removeDeviceIdsForNumber(number, [device]); + } else { + throw e; + } + }.bind(this)); }.bind(this)); }.bind(this)); diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index 0444fb12..cd1cf577 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -69,7 +69,13 @@ OutgoingMessage.prototype = { var promise = Promise.resolve(); updateDevices.forEach(function(device) { promise = promise.then(function() { - return this.server.getKeysForNumber(number, device).then(handleResult); + return this.server.getKeysForNumber(number, device).then(handleResult).catch(function(e) { + if (e.name === 'HTTPError' && e.code === 404 && device !== 1) { + return this.removeDeviceIdsForNumber(number, [device]); + } else { + throw e; + } + }.bind(this)); }.bind(this)); }.bind(this));