Move to the real verify/trust APIs

This wires up verification sync messages, verification and trust checks
to the trust store instead of using mocked data.

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-06-15 16:37:20 -07:00
parent 52481d1d13
commit c43d96904d
2 changed files with 26 additions and 38 deletions

View file

@ -119,7 +119,7 @@
messageReceiver.addEventListener('group', onGroupReceived);
messageReceiver.addEventListener('sent', onSentMessage);
messageReceiver.addEventListener('read', onReadReceipt);
messageReceiver.addEventListener('verification', onVerify);
messageReceiver.addEventListener('verification', onVerification);
messageReceiver.addEventListener('error', onError);
@ -291,23 +291,33 @@
});
}
var VERIFIED_ENUM = textsecure.storage.protocol.VerifiedStatus;
function onVerify(ev) {
function onVerification(ev) {
var number = ev.destination;
var key = ev.identityKey;
var verified = ev.state;
var state;
console.log('verification sync message', number, verified);
console.log('got verification sync for', number, 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;
}
var contact = ConversationController.get(number);
if (!contact) {
return;
}
if (verified === VERIFIED_ENUM.DEFAULT) {
if (state === 'DEFAULT') {
contact.setVerifiedDefault({viaSyncMessage: true, key: key});
} else if (verified === VERIFIED_ENUM.VERIFIED) {
} else if (state === 'VERIFIED') {
contact.setVerified({viaSyncMessage: true, key: key});
}
}