Fixes to get local verification and sync messages working

FREEBIE
pull/749/head
Scott Nonnenberg 8 years ago
parent c43d96904d
commit 4a1dc46ab3

@ -292,20 +292,20 @@
} }
function onVerification(ev) { function onVerification(ev) {
var number = ev.destination; var number = ev.verification.destination;
var key = ev.identityKey; var key = ev.verification.identityKey;
var state; var state;
console.log('got verification sync for', number, state); console.log('got verification sync for', number, state);
switch(ev.state) { switch(ev.verification.state) {
case textsecure.protobuf.Verification.State.DEFAULT: case textsecure.protobuf.SyncMessage.Verification.State.DEFAULT:
state = 'DEFAULT'; state = 'DEFAULT';
break; break;
case textsecure.protobuf.Verification.State.VERIFIED: case textsecure.protobuf.SyncMessage.Verification.State.VERIFIED:
state = 'VERIFIED'; state = 'VERIFIED';
break; break;
case textsecure.protobuf.Verification.State.NO_LONGER_VERIFIED: case textsecure.protobuf.SyncMessage.Verification.State.NO_LONGER_VERIFIED:
state = 'UNVERIFIED'; state = 'UNVERIFIED';
break; 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 = { window.owsDesktopApp = {
getAppView: function(destWindow) { getAppView: function(destWindow) {

@ -234,7 +234,6 @@
attributes.firstUse = false; attributes.firstUse = false;
attributes.nonblockingApproval = false; attributes.nonblockingApproval = false;
attributes.verified = 0; attributes.verified = 0;
attributes.seen = 0;
promises.push(new Promise(function(resolve, reject) { promises.push(new Promise(function(resolve, reject) {
var putRequest = identityKeys.put(attributes, attributes.id); var putRequest = identityKeys.put(attributes, attributes.id);
putRequest.onsuccess = resolve; putRequest.onsuccess = resolve;

@ -38122,7 +38122,7 @@ var TextSecureServer = (function() {
// update our own identity key, which may have changed // update our own identity key, which may have changed
// if we're relinking after a reinstall on the master device // if we're relinking after a reinstall on the master device
textsecure.storage.protocol.saveIdentityWithAttributes({ textsecure.storage.protocol.saveIdentityWithAttributes(number, {
id : number, id : number,
publicKey : identityKeyPair.pubKey, publicKey : identityKeyPair.pubKey,
firstUse : true, firstUse : true,
@ -38477,7 +38477,7 @@ MessageReceiver.prototype.extend({
this.handleBlocked(syncMessage.blocked); this.handleBlocked(syncMessage.blocked);
} else if (syncMessage.request) { } else if (syncMessage.request) {
console.log('Got SyncMessage Request'); console.log('Got SyncMessage Request');
} else if (syncMessage.read) { } else if (syncMessage.read && syncMessage.read.length) {
console.log('read messages', console.log('read messages',
'from', envelope.source + '.' + envelope.sourceDevice); 'from', envelope.source + '.' + envelope.sourceDevice);
this.handleRead(syncMessage.read, envelope.timestamp); this.handleRead(syncMessage.read, envelope.timestamp);
@ -39263,7 +39263,7 @@ MessageSender.prototype = {
return this.sendIndividualProto(myNumber, contentMessage, Date.now()); return this.sendIndividualProto(myNumber, contentMessage, Date.now());
} }
}, },
syncVerification: function(state, destination, identityKey) { syncVerification: function(destination, state, identityKey) {
var myNumber = textsecure.storage.user.getNumber(); var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId(); var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) { if (myDevice != 1) {
@ -39526,7 +39526,7 @@ textsecure.MessageSender = function(url, ports, username, password) {
this.sendSyncMessage = sender.sendSyncMessage .bind(sender); this.sendSyncMessage = sender.sendSyncMessage .bind(sender);
this.getProfile = sender.getProfile .bind(sender); this.getProfile = sender.getProfile .bind(sender);
this.syncReadMessages = sender.syncReadMessages .bind(sender); this.syncReadMessages = sender.syncReadMessages .bind(sender);
this.syncVerification = sender.syncReadMessages .bind(sender); this.syncVerification = sender.syncVerification .bind(sender);
}; };
textsecure.MessageSender.prototype = { textsecure.MessageSender.prototype = {

@ -78,13 +78,16 @@
options = options || {}; options = options || {};
_.defaults(options, {viaSyncMessage: false, key: null}); _.defaults(options, {viaSyncMessage: false, key: null});
var DEFAULT = this.verifiedEnum.DEFAULT;
if (!this.isPrivate()) { if (!this.isPrivate()) {
throw new Error('You cannot verify a group conversation. ' + throw new Error('You cannot verify a group conversation. ' +
'You must verify individual contacts.'); '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}); return this.save({verified: DEFAULT});
}.bind(this)).then(function() { }.bind(this)).then(function() {
this.addVerifiedChange(this.id, false); this.addVerifiedChange(this.id, false);
@ -104,7 +107,9 @@
'You must verify individual contacts.'); '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}); return this.save({verified: VERIFIED});
}.bind(this)).then(function() { }.bind(this)).then(function() {
this.addVerifiedChange(this.id, true); this.addVerifiedChange(this.id, true);
@ -115,7 +120,7 @@
}, },
sendVerifySyncMessage: function(number, state) { sendVerifySyncMessage: function(number, state) {
textsecure.storage.protocol.loadIdentityKey(number).then(function(key) { textsecure.storage.protocol.loadIdentityKey(number).then(function(key) {
textsecure.storage.protocol.syncVerification(number, state, key); textsecure.messaging.syncVerification(number, state, key);
}); });
}, },
isVerified: function() { isVerified: function() {

@ -203,7 +203,7 @@
// update our own identity key, which may have changed // update our own identity key, which may have changed
// if we're relinking after a reinstall on the master device // if we're relinking after a reinstall on the master device
textsecure.storage.protocol.saveIdentityWithAttributes({ textsecure.storage.protocol.saveIdentityWithAttributes(number, {
id : number, id : number,
publicKey : identityKeyPair.pubKey, publicKey : identityKeyPair.pubKey,
firstUse : true, firstUse : true,

@ -268,7 +268,7 @@ MessageReceiver.prototype.extend({
this.handleBlocked(syncMessage.blocked); this.handleBlocked(syncMessage.blocked);
} else if (syncMessage.request) { } else if (syncMessage.request) {
console.log('Got SyncMessage Request'); console.log('Got SyncMessage Request');
} else if (syncMessage.read) { } else if (syncMessage.read && syncMessage.read.length) {
console.log('read messages', console.log('read messages',
'from', envelope.source + '.' + envelope.sourceDevice); 'from', envelope.source + '.' + envelope.sourceDevice);
this.handleRead(syncMessage.read, envelope.timestamp); this.handleRead(syncMessage.read, envelope.timestamp);

@ -305,7 +305,7 @@ MessageSender.prototype = {
return this.sendIndividualProto(myNumber, contentMessage, Date.now()); return this.sendIndividualProto(myNumber, contentMessage, Date.now());
} }
}, },
syncVerification: function(state, destination, identityKey) { syncVerification: function(destination, state, identityKey) {
var myNumber = textsecure.storage.user.getNumber(); var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId(); var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) { if (myDevice != 1) {
@ -568,7 +568,7 @@ textsecure.MessageSender = function(url, ports, username, password) {
this.sendSyncMessage = sender.sendSyncMessage .bind(sender); this.sendSyncMessage = sender.sendSyncMessage .bind(sender);
this.getProfile = sender.getProfile .bind(sender); this.getProfile = sender.getProfile .bind(sender);
this.syncReadMessages = sender.syncReadMessages .bind(sender); this.syncReadMessages = sender.syncReadMessages .bind(sender);
this.syncVerification = sender.syncReadMessages .bind(sender); this.syncVerification = sender.syncVerification .bind(sender);
}; };
textsecure.MessageSender.prototype = { textsecure.MessageSender.prototype = {

Loading…
Cancel
Save