From d2ddfc72e43af12ab249eab4d27c4d9e22813b5b Mon Sep 17 00:00:00 2001 From: haffenloher Date: Wed, 8 Feb 2017 17:59:32 +0100 Subject: [PATCH] Throw UnregisteredUserErrors in getKeysForNumber() --- js/libtextsecure.js | 5 +++-- libtextsecure/outgoing_message.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 9c247dbf..87b1278a 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38640,8 +38640,9 @@ OutgoingMessage.prototype = { updateDevices.forEach(function(device) { promise = promise.then(function() { 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]); + if (e.name === 'HTTPError' && e.code === 404) { + if (device !== 1) return this.removeDeviceIdsForNumber(number, [device]); + else throw new textsecure.UnregisteredUserError(number, e); } else { throw e; } diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index ac78ea4c..64cbb099 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -70,8 +70,9 @@ OutgoingMessage.prototype = { updateDevices.forEach(function(device) { promise = promise.then(function() { 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]); + if (e.name === 'HTTPError' && e.code === 404) { + if (device !== 1) return this.removeDeviceIdsForNumber(number, [device]); + else throw new textsecure.UnregisteredUserError(number, e); } else { throw e; }