Add contact sync request protocol

This commit is contained in:
lilia 2015-06-19 15:34:41 -07:00
parent f32ff58953
commit 2f935dfd5e
4 changed files with 49 additions and 4 deletions

View file

@ -39330,7 +39330,8 @@ TextSecureServer = function () {
return createAccount(number, verificationCode, identityKeyPair, true).
then(function() { return generateKeys(100); }).
then(TextSecureServer.registerKeys).
then(textsecure.registration.done);
then(textsecure.registration.done).
then(textsecure.messaging.sendRequestContactSyncMessage);
});
},
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
@ -39369,7 +39370,9 @@ TextSecureServer = function () {
});
}).then(function() {
return generateKeys(100, progressCallback);
}).then(TextSecureServer.registerKeys).then(textsecure.registration.done);
}).then(TextSecureServer.registerKeys).
then(textsecure.registration.done).
then(textsecure.messaging.sendRequestContactSyncMessage);
},
refreshPreKeys: function() {
return TextSecureServer.getMyKeys().then(function(preKeyCount) {
@ -39946,6 +39949,21 @@ window.textsecure.messaging = function() {
}
}
self.sendRequestContactSyncMessage = function() {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
var request = new textsecure.protobuf.SyncMessage.Request();
request.type = textsecure.protobuf.SyncMessage.Request.Type.CONTACTS;
var syncMessage = new textsecure.protobuf.SyncMessage();
syncMessage.request = request;
var contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage;
return sendIndividualProto(myNumber, contentMessage, Date.now());
}
};
var sendGroupProto = function(numbers, proto, timestamp) {
timestamp = timestamp || Date.now();
var me = textsecure.storage.user.getNumber();

View file

@ -35,7 +35,8 @@
return createAccount(number, verificationCode, identityKeyPair, true).
then(function() { return generateKeys(100); }).
then(TextSecureServer.registerKeys).
then(textsecure.registration.done);
then(textsecure.registration.done).
then(textsecure.messaging.sendRequestContactSyncMessage);
});
},
registerSecondDevice: function(setProvisioningUrl, confirmNumber, progressCallback) {
@ -74,7 +75,9 @@
});
}).then(function() {
return generateKeys(100, progressCallback);
}).then(TextSecureServer.registerKeys).then(textsecure.registration.done);
}).then(TextSecureServer.registerKeys).
then(textsecure.registration.done).
then(textsecure.messaging.sendRequestContactSyncMessage);
},
refreshPreKeys: function() {
return TextSecureServer.getMyKeys().then(function(preKeyCount) {

View file

@ -290,6 +290,21 @@ window.textsecure.messaging = function() {
}
}
self.sendRequestContactSyncMessage = function() {
var myNumber = textsecure.storage.user.getNumber();
var myDevice = textsecure.storage.user.getDeviceId();
if (myDevice != 1) {
var request = new textsecure.protobuf.SyncMessage.Request();
request.type = textsecure.protobuf.SyncMessage.Request.Type.CONTACTS;
var syncMessage = new textsecure.protobuf.SyncMessage();
syncMessage.request = request;
var contentMessage = new textsecure.protobuf.Content();
contentMessage.syncMessage = syncMessage;
return sendIndividualProto(myNumber, contentMessage, Date.now());
}
};
var sendGroupProto = function(numbers, proto, timestamp) {
timestamp = timestamp || Date.now();
var me = textsecure.storage.user.getNumber();

View file

@ -52,9 +52,18 @@ message SyncMessage {
optional GroupContext group = 1;
}
message Request {
enum Type {
UNKNOWN = 0;
CONTACTS = 1;
}
optional Type type = 1;
}
optional Sent sent = 1;
optional Contacts contacts = 2;
optional Group group = 3;
optional Request request = 4;
}
message AttachmentPointer {