Add textsecure.refreshKeys

This helper checks the server for the number of remaining prekeys, then
generates more if there are fewer than 10 remaining.

// FREEBIE
pull/749/head
lilia 10 years ago
parent 96eafc7750
commit a960acacc6

@ -38913,6 +38913,14 @@ textsecure.processDecrypted = function(decrypted, source) {
});
};
window.textsecure.refreshPreKeys = function() {
return textsecure.api.getMyKeys().then(function(preKeyCount) {
if (preKeyCount < 10) {
generateKeys();
}
});
};
function createAccount(number, verificationCode, identityKeyPair, single_device) {
textsecure.storage.put('identityKey', identityKeyPair);
@ -39331,6 +39339,16 @@ window.textsecure.api = function () {
});
};
self.getMyKeys = function(number, deviceId) {
return doAjax({
call : 'keys',
httpType : 'GET',
do_auth : true,
}).then(function(res) {
return parseInt(res.count);
});
};
self.getKeysForNumber = function(number, deviceId) {
if (deviceId === undefined)
deviceId = "*";

@ -216,6 +216,16 @@ window.textsecure.api = function () {
});
};
self.getMyKeys = function(number, deviceId) {
return doAjax({
call : 'keys',
httpType : 'GET',
do_auth : true,
}).then(function(res) {
return parseInt(res.count);
});
};
self.getKeysForNumber = function(number, deviceId) {
if (deviceId === undefined)
deviceId = "*";

@ -248,6 +248,14 @@ textsecure.processDecrypted = function(decrypted, source) {
});
};
window.textsecure.refreshPreKeys = function() {
return textsecure.api.getMyKeys().then(function(preKeyCount) {
if (preKeyCount < 10) {
generateKeys();
}
});
};
function createAccount(number, verificationCode, identityKeyPair, single_device) {
textsecure.storage.put('identityKey', identityKeyPair);

Loading…
Cancel
Save