From adf8445b854fa0932617983c35ac4039eb4dd93e Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 17 Nov 2015 11:56:45 -0800 Subject: [PATCH] Populate registrationIds on deviceObjects Saves us from doing so later. // FREEBIE --- js/libtextsecure.js | 11 ++++++++--- libtextsecure/storage/devices.js | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index a7ac81d8..c01f8e29 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -35530,13 +35530,18 @@ axolotlInternal.RecipientRecord = function() { deviceIds.push(deviceId); } } - return deviceIds.map(function(deviceId) { + return Promise.all(deviceIds.map(function(deviceId) { var encodedNumber = number + '.' + deviceId; var deviceObject = tempKeys[encodedNumber] || {}; deviceObject.encodedNumber = encodedNumber; deviceObject.identityKey = identityKey; - return deviceObject; - }); + return textsecure.protocol_wrapper.getRegistrationId(encodedNumber).then(function(registrationId) { + if (deviceObject.registrationId === undefined) { + deviceObject.registrationId = registrationId; + } + return deviceObject; + }); + })); }); }); }, diff --git a/libtextsecure/storage/devices.js b/libtextsecure/storage/devices.js index 3f7b6a93..1e4dcbbe 100644 --- a/libtextsecure/storage/devices.js +++ b/libtextsecure/storage/devices.js @@ -73,13 +73,18 @@ deviceIds.push(deviceId); } } - return deviceIds.map(function(deviceId) { + return Promise.all(deviceIds.map(function(deviceId) { var encodedNumber = number + '.' + deviceId; var deviceObject = tempKeys[encodedNumber] || {}; deviceObject.encodedNumber = encodedNumber; deviceObject.identityKey = identityKey; - return deviceObject; - }); + return textsecure.protocol_wrapper.getRegistrationId(encodedNumber).then(function(registrationId) { + if (deviceObject.registrationId === undefined) { + deviceObject.registrationId = registrationId; + } + return deviceObject; + }); + })); }); }); },