From a9549e2e0f2579897406f28195f1cfc66067297c Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 4 Jun 2015 11:55:35 -0700 Subject: [PATCH] Fix 410 handling We need to close the existing session with an old registrationId. --- js/libtextsecure.js | 4 +++- libtextsecure/sendmessage.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 7b633dabd..993c8ce91 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -39721,7 +39721,9 @@ window.textsecure.messaging = function() { if (error.message == 409) { p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices); } else { - p = Promise.resolve(); + p = Promise.all(error.response.staleDevices.map(function(deviceId) { + return textsecure.protocol_wrapper.closeOpenSessionForDevice(number + '.' + deviceId); + })); } p.then(function() { diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 263a28595..e4b8ad0cd 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -196,7 +196,9 @@ window.textsecure.messaging = function() { if (error.message == 409) { p = textsecure.storage.devices.removeDeviceIdsForNumber(number, error.response.extraDevices); } else { - p = Promise.resolve(); + p = Promise.all(error.response.staleDevices.map(function(deviceId) { + return textsecure.protocol_wrapper.closeOpenSessionForDevice(number + '.' + deviceId); + })); } p.then(function() {