Protos: Move to latest iteration of verification protos
FREEBIE
This commit is contained in:
parent
3360f65fac
commit
20f4d48991
5 changed files with 52 additions and 52 deletions
|
@ -119,7 +119,7 @@
|
||||||
messageReceiver.addEventListener('group', onGroupReceived);
|
messageReceiver.addEventListener('group', onGroupReceived);
|
||||||
messageReceiver.addEventListener('sent', onSentMessage);
|
messageReceiver.addEventListener('sent', onSentMessage);
|
||||||
messageReceiver.addEventListener('read', onReadReceipt);
|
messageReceiver.addEventListener('read', onReadReceipt);
|
||||||
messageReceiver.addEventListener('verification', onVerification);
|
messageReceiver.addEventListener('verified', onVerified);
|
||||||
messageReceiver.addEventListener('error', onError);
|
messageReceiver.addEventListener('error', onError);
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,21 +291,21 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onVerification(ev) {
|
function onVerified(ev) {
|
||||||
var number = ev.verification.destination;
|
var number = ev.verified.destination;
|
||||||
var key = ev.verification.identityKey;
|
var key = ev.verified.identityKey;
|
||||||
var state;
|
var state;
|
||||||
|
|
||||||
console.log('got verification sync for', number, state);
|
console.log('got verified sync for', number, state);
|
||||||
|
|
||||||
switch(ev.verification.state) {
|
switch(ev.verified.state) {
|
||||||
case textsecure.protobuf.SyncMessage.Verification.State.DEFAULT:
|
case textsecure.protobuf.SyncMessage.Verified.State.DEFAULT:
|
||||||
state = 'DEFAULT';
|
state = 'DEFAULT';
|
||||||
break;
|
break;
|
||||||
case textsecure.protobuf.SyncMessage.Verification.State.VERIFIED:
|
case textsecure.protobuf.SyncMessage.Verified.State.VERIFIED:
|
||||||
state = 'VERIFIED';
|
state = 'VERIFIED';
|
||||||
break;
|
break;
|
||||||
case textsecure.protobuf.SyncMessage.Verification.State.NO_LONGER_VERIFIED:
|
case textsecure.protobuf.SyncMessage.Verified.State.UNVERIFIED:
|
||||||
state = 'UNVERIFIED';
|
state = 'UNVERIFIED';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38481,19 +38481,19 @@ MessageReceiver.prototype.extend({
|
||||||
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);
|
||||||
} else if (syncMessage.verification) {
|
} else if (syncMessage.verified) {
|
||||||
this.handleVerification(syncMessage.verification);
|
this.handleVerified(syncMessage.verified);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Got empty SyncMessage');
|
throw new Error('Got empty SyncMessage');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleVerification: function(verification) {
|
handleVerified: function(verified) {
|
||||||
for (var i = 0; i < verification.length; ++i) {
|
for (var i = 0; i < verified.length; ++i) {
|
||||||
var ev = new Event('verification');
|
var ev = new Event('verified');
|
||||||
ev.verification = {
|
ev.verified = {
|
||||||
state: verification[i].state,
|
state: verified[i].state,
|
||||||
destination: verification[i].destination,
|
destination: verified[i].destination,
|
||||||
identityKey: verification[i].identityKey.toArrayBuffer()
|
identityKey: verified[i].identityKey.toArrayBuffer()
|
||||||
};
|
};
|
||||||
this.dispatchEvent(ev);
|
this.dispatchEvent(ev);
|
||||||
}
|
}
|
||||||
|
@ -39271,13 +39271,13 @@ MessageSender.prototype = {
|
||||||
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) {
|
||||||
var verification = new textsecure.protobuf.SyncMessage.Verification();
|
var verified = new textsecure.protobuf.SyncMessage.Verified();
|
||||||
verification.state = state;
|
verified.state = state;
|
||||||
verification.destination = destination;
|
verified.destination = destination;
|
||||||
verification.identityKey = identityKey;
|
verified.identityKey = identityKey;
|
||||||
|
|
||||||
var syncMessage = new textsecure.protobuf.SyncMessage();
|
var syncMessage = new textsecure.protobuf.SyncMessage();
|
||||||
syncMessage.verification = verification;
|
syncMessage.verified = verified;
|
||||||
|
|
||||||
var contentMessage = new textsecure.protobuf.Content();
|
var contentMessage = new textsecure.protobuf.Content();
|
||||||
contentMessage.syncMessage = syncMessage;
|
contentMessage.syncMessage = syncMessage;
|
||||||
|
|
|
@ -272,19 +272,19 @@ MessageReceiver.prototype.extend({
|
||||||
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);
|
||||||
} else if (syncMessage.verification) {
|
} else if (syncMessage.verified) {
|
||||||
this.handleVerification(syncMessage.verification);
|
this.handleVerified(syncMessage.verified);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Got empty SyncMessage');
|
throw new Error('Got empty SyncMessage');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleVerification: function(verification) {
|
handleVerified: function(verified) {
|
||||||
for (var i = 0; i < verification.length; ++i) {
|
for (var i = 0; i < verified.length; ++i) {
|
||||||
var ev = new Event('verification');
|
var ev = new Event('verified');
|
||||||
ev.verification = {
|
ev.verified = {
|
||||||
state: verification[i].state,
|
state: verified[i].state,
|
||||||
destination: verification[i].destination,
|
destination: verified[i].destination,
|
||||||
identityKey: verification[i].identityKey.toArrayBuffer()
|
identityKey: verified[i].identityKey.toArrayBuffer()
|
||||||
};
|
};
|
||||||
this.dispatchEvent(ev);
|
this.dispatchEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,13 +309,13 @@ MessageSender.prototype = {
|
||||||
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) {
|
||||||
var verification = new textsecure.protobuf.SyncMessage.Verification();
|
var verified = new textsecure.protobuf.SyncMessage.Verified();
|
||||||
verification.state = state;
|
verified.state = state;
|
||||||
verification.destination = destination;
|
verified.destination = destination;
|
||||||
verification.identityKey = identityKey;
|
verified.identityKey = identityKey;
|
||||||
|
|
||||||
var syncMessage = new textsecure.protobuf.SyncMessage();
|
var syncMessage = new textsecure.protobuf.SyncMessage();
|
||||||
syncMessage.verification = verification;
|
syncMessage.verified = verified;
|
||||||
|
|
||||||
var contentMessage = new textsecure.protobuf.Content();
|
var contentMessage = new textsecure.protobuf.Content();
|
||||||
contentMessage.syncMessage = syncMessage;
|
contentMessage.syncMessage = syncMessage;
|
||||||
|
|
|
@ -111,17 +111,16 @@ message SyncMessage {
|
||||||
optional uint64 timestamp = 2;
|
optional uint64 timestamp = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Verification {
|
message Verified {
|
||||||
enum State {
|
enum State {
|
||||||
DEFAULT = 0;
|
DEFAULT = 0;
|
||||||
VERIFIED = 1;
|
VERIFIED = 1;
|
||||||
NO_LONGER_VERIFIED = 2;
|
UNVERIFIED = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional State state = 1;
|
optional string destination = 1;
|
||||||
// The e164 phone number of the user.
|
optional bytes identityKey = 2;
|
||||||
optional string destination = 2;
|
optional State state = 3;
|
||||||
optional bytes identityKey = 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
optional Sent sent = 1;
|
optional Sent sent = 1;
|
||||||
|
@ -130,7 +129,8 @@ message SyncMessage {
|
||||||
optional Request request = 4;
|
optional Request request = 4;
|
||||||
repeated Read read = 5;
|
repeated Read read = 5;
|
||||||
optional Blocked blocked = 6;
|
optional Blocked blocked = 6;
|
||||||
repeated Verification verification = 7;
|
repeated Verified verified = 7;
|
||||||
|
optional bytes padding = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AttachmentPointer {
|
message AttachmentPointer {
|
||||||
|
|
Loading…
Reference in a new issue