Fixes to get local verification and sync messages working

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-06-15 18:11:18 -07:00
parent c43d96904d
commit 4a1dc46ab3
7 changed files with 23 additions and 42 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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 = {

View File

@ -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() {

View File

@ -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,

View File

@ -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);

View File

@ -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 = {