From 4f2f622598f888e78682857b884981c0fa104e7d Mon Sep 17 00:00:00 2001 From: lilia Date: Fri, 16 Jun 2017 18:38:36 -0700 Subject: [PATCH] Apply special handling to verification sync messages // FREEBIE --- js/models/conversations.js | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index cad6c4003..79716b48a 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -85,9 +85,20 @@ 'You must verify individual contacts.'); } - // TODO: handle the incoming key from the sync messages - need different behavior - // if that key doesn't match the current key - return textsecure.storage.protocol.setVerified(this.id, DEFAULT).then(function() { + var promise; + if (options.viaSyncMessage) { + // handle the incoming key from the sync messages - need different + // behavior if that key doesn't match the current key + promise = textsecure.storage.protocol.processVerifiedMessage( + this.id, DEFAULT, options.key + ); + } else { + promise = textsecure.storage.protocol.setVerified( + this.id, DEFAULT + ); + } + + return promise.then(function() { return this.save({verified: DEFAULT}); }.bind(this)).then(function() { this.addVerifiedChange(this.id, false); @@ -107,9 +118,20 @@ 'You must verify individual contacts.'); } - // TODO: handle the incoming key from the sync messages - need different behavior - // if that key doesn't match the current key - return textsecure.storage.protocol.setVerified(this.id, VERIFIED).then(function() { + var promise; + if (options.viaSyncMessage) { + // handle the incoming key from the sync messages - need different + // behavior if that key doesn't match the current key + promise = textsecure.storage.protocol.processVerifiedMessage( + this.id, VERIFIED, options.key + ); + } else { + promise = textsecure.storage.protocol.setVerified( + this.id, VERIFIED + ); + } + + return promise.then(function() { return this.save({verified: VERIFIED}); }.bind(this)).then(function() { this.addVerifiedChange(this.id, true);