From 261ec003eeee2f28b9940c608b3b2e4f6d584e19 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 13 Jun 2017 12:59:47 -0700 Subject: [PATCH] Account manager calls saveIdentityWithAtttributes saveIdentityWithAtttributes allows directly setting all properties of an identity key record. In AccountManager we use it to save our own identity key after a new registration. Previously we would remove the existing key first in order to coerce firstUse to true, but now we can simply set it explicitly, along with a VERIFIED status. // FREEBIE --- js/libtextsecure.js | 12 ++++++++---- libtextsecure/account_manager.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 2c9fa0aeb..f456c6a77 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38122,10 +38122,14 @@ var TextSecureServer = (function() { // update our own identity key, which may have changed // if we're relinking after a reinstall on the master device - var putIdentity = textsecure.storage.protocol.saveIdentity.bind( - null, number, identityKeyPair.pubKey, true, true - ); - textsecure.storage.protocol.removeIdentityKey(number).then(putIdentity, putIdentity); + textsecure.storage.protocol.saveIdentityWithAttributes({ + id : number, + publicKey : identityKeyPair.pubKey, + firstUse : true, + timestamp : Date.now(), + verified : textsecure.storage.protocol.VerifiedStatus.VERIFIED, + nonblockingApproval : true + }); textsecure.storage.put('identityKey', identityKeyPair); textsecure.storage.put('signaling_key', signalingKey); diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index ad0a43a03..b12c09ccd 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -203,10 +203,14 @@ // update our own identity key, which may have changed // if we're relinking after a reinstall on the master device - var putIdentity = textsecure.storage.protocol.saveIdentity.bind( - null, number, identityKeyPair.pubKey, true, true - ); - textsecure.storage.protocol.removeIdentityKey(number).then(putIdentity, putIdentity); + textsecure.storage.protocol.saveIdentityWithAttributes({ + id : number, + publicKey : identityKeyPair.pubKey, + firstUse : true, + timestamp : Date.now(), + verified : textsecure.storage.protocol.VerifiedStatus.VERIFIED, + nonblockingApproval : true + }); textsecure.storage.put('identityKey', identityKeyPair); textsecure.storage.put('signaling_key', signalingKey);