diff --git a/js/background.js b/js/background.js index ef71ce6f4..d976827d6 100644 --- a/js/background.js +++ b/js/background.js @@ -292,20 +292,20 @@ } function onVerification(ev) { - var number = ev.destination; - var key = ev.identityKey; + var number = ev.verification.destination; + var key = ev.verification.identityKey; var state; console.log('got verification sync for', number, state); - switch(ev.state) { - case textsecure.protobuf.Verification.State.DEFAULT: + switch(ev.verification.state) { + case textsecure.protobuf.SyncMessage.Verification.State.DEFAULT: state = 'DEFAULT'; break; - case textsecure.protobuf.Verification.State.VERIFIED: + case textsecure.protobuf.SyncMessage.Verification.State.VERIFIED: state = 'VERIFIED'; break; - case textsecure.protobuf.Verification.State.NO_LONGER_VERIFIED: + case textsecure.protobuf.SyncMessage.Verification.State.NO_LONGER_VERIFIED: state = 'UNVERIFIED'; break; } @@ -336,29 +336,6 @@ }); } - function onVerification(ev) { - var state; - switch(ev.state) { - case textsecure.protobuf.Verification.State.DEFAULT: - state = 'DEFAULT'; - break; - case textsecure.protobuf.Verification.State.VERIFIED: - state = 'VERIFIED'; - break; - case textsecure.protobuf.Verification.State.NO_LONGER_VERIFIED: - state = 'UNVERIFIED'; - break; - } - console.log('got verification sync for', ev.destination, state); - /* TODO - processVerifiedMessage( - textsecure.storage.protocol.VerifiedStatus[state], - ev.destination, - ev.identityKey - ); - */ - } - window.owsDesktopApp = { getAppView: function(destWindow) { diff --git a/js/database.js b/js/database.js index 1126e62d8..6be7a3019 100644 --- a/js/database.js +++ b/js/database.js @@ -234,7 +234,6 @@ attributes.firstUse = false; attributes.nonblockingApproval = false; attributes.verified = 0; - attributes.seen = 0; promises.push(new Promise(function(resolve, reject) { var putRequest = identityKeys.put(attributes, attributes.id); putRequest.onsuccess = resolve; diff --git a/js/libtextsecure.js b/js/libtextsecure.js index 7767ea6df..499a43b06 100644 --- a/js/libtextsecure.js +++ b/js/libtextsecure.js @@ -38122,7 +38122,7 @@ var TextSecureServer = (function() { // update our own identity key, which may have changed // if we're relinking after a reinstall on the master device - textsecure.storage.protocol.saveIdentityWithAttributes({ + textsecure.storage.protocol.saveIdentityWithAttributes(number, { id : number, publicKey : identityKeyPair.pubKey, firstUse : true, @@ -38477,7 +38477,7 @@ MessageReceiver.prototype.extend({ this.handleBlocked(syncMessage.blocked); } else if (syncMessage.request) { console.log('Got SyncMessage Request'); - } else if (syncMessage.read) { + } else if (syncMessage.read && syncMessage.read.length) { console.log('read messages', 'from', envelope.source + '.' + envelope.sourceDevice); this.handleRead(syncMessage.read, envelope.timestamp); @@ -39263,7 +39263,7 @@ MessageSender.prototype = { return this.sendIndividualProto(myNumber, contentMessage, Date.now()); } }, - syncVerification: function(state, destination, identityKey) { + syncVerification: function(destination, state, identityKey) { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); if (myDevice != 1) { @@ -39526,7 +39526,7 @@ textsecure.MessageSender = function(url, ports, username, password) { this.sendSyncMessage = sender.sendSyncMessage .bind(sender); this.getProfile = sender.getProfile .bind(sender); this.syncReadMessages = sender.syncReadMessages .bind(sender); - this.syncVerification = sender.syncReadMessages .bind(sender); + this.syncVerification = sender.syncVerification .bind(sender); }; textsecure.MessageSender.prototype = { diff --git a/js/models/conversations.js b/js/models/conversations.js index dc8f2be99..71bea46fd 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -78,13 +78,16 @@ options = options || {}; _.defaults(options, {viaSyncMessage: false, key: null}); + var DEFAULT = this.verifiedEnum.DEFAULT; + if (!this.isPrivate()) { throw new Error('You cannot verify a group conversation. ' + 'You must verify individual contacts.'); } - var DEFAULT = this.verifiedEnum.DEFAULT; - return textsecure.storage.protocol.setVerified(this.id, DEFAULT, options.key).then(function() { + // 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() { return this.save({verified: DEFAULT}); }.bind(this)).then(function() { this.addVerifiedChange(this.id, false); @@ -104,7 +107,9 @@ 'You must verify individual contacts.'); } - return textsecure.storage.protocol.setVerified(this.id, VERIFIED, options.key).then(function() { + // 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() { return this.save({verified: VERIFIED}); }.bind(this)).then(function() { this.addVerifiedChange(this.id, true); @@ -115,7 +120,7 @@ }, sendVerifySyncMessage: function(number, state) { textsecure.storage.protocol.loadIdentityKey(number).then(function(key) { - textsecure.storage.protocol.syncVerification(number, state, key); + textsecure.messaging.syncVerification(number, state, key); }); }, isVerified: function() { diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index b12c09ccd..8ba9d0d94 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -203,7 +203,7 @@ // update our own identity key, which may have changed // if we're relinking after a reinstall on the master device - textsecure.storage.protocol.saveIdentityWithAttributes({ + textsecure.storage.protocol.saveIdentityWithAttributes(number, { id : number, publicKey : identityKeyPair.pubKey, firstUse : true, diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index e96f06e4b..045f0adb7 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -268,7 +268,7 @@ MessageReceiver.prototype.extend({ this.handleBlocked(syncMessage.blocked); } else if (syncMessage.request) { console.log('Got SyncMessage Request'); - } else if (syncMessage.read) { + } else if (syncMessage.read && syncMessage.read.length) { console.log('read messages', 'from', envelope.source + '.' + envelope.sourceDevice); this.handleRead(syncMessage.read, envelope.timestamp); diff --git a/libtextsecure/sendmessage.js b/libtextsecure/sendmessage.js index 5b32ffc7c..4e6985789 100644 --- a/libtextsecure/sendmessage.js +++ b/libtextsecure/sendmessage.js @@ -305,7 +305,7 @@ MessageSender.prototype = { return this.sendIndividualProto(myNumber, contentMessage, Date.now()); } }, - syncVerification: function(state, destination, identityKey) { + syncVerification: function(destination, state, identityKey) { var myNumber = textsecure.storage.user.getNumber(); var myDevice = textsecure.storage.user.getDeviceId(); if (myDevice != 1) { @@ -568,7 +568,7 @@ textsecure.MessageSender = function(url, ports, username, password) { this.sendSyncMessage = sender.sendSyncMessage .bind(sender); this.getProfile = sender.getProfile .bind(sender); this.syncReadMessages = sender.syncReadMessages .bind(sender); - this.syncVerification = sender.syncReadMessages .bind(sender); + this.syncVerification = sender.syncVerification .bind(sender); }; textsecure.MessageSender.prototype = {