Move groups storage back to libtextsecure
This commit is contained in:
parent
04b2a13a75
commit
3e648b0ea0
3 changed files with 8 additions and 20 deletions
|
@ -78,7 +78,6 @@ module.exports = function(grunt) {
|
||||||
'libaxolotl/webcrypto_concat.js',
|
'libaxolotl/webcrypto_concat.js',
|
||||||
'libaxolotl/components.js',
|
'libaxolotl/components.js',
|
||||||
|
|
||||||
'libaxolotl/groups_storage.js',
|
|
||||||
'libaxolotl/crypto.js',
|
'libaxolotl/crypto.js',
|
||||||
'libaxolotl/protocol.js',
|
'libaxolotl/protocol.js',
|
||||||
'libaxolotl/protobufs.js',
|
'libaxolotl/protobufs.js',
|
||||||
|
@ -95,6 +94,7 @@ module.exports = function(grunt) {
|
||||||
'libtextsecure/crypto.js',
|
'libtextsecure/crypto.js',
|
||||||
'libtextsecure/storage.js',
|
'libtextsecure/storage.js',
|
||||||
'libtextsecure/storage/devices.js',
|
'libtextsecure/storage/devices.js',
|
||||||
|
'libtextsecure/storage/groups.js',
|
||||||
'libtextsecure/protobufs.js',
|
'libtextsecure/protobufs.js',
|
||||||
'libtextsecure/websocket.js',
|
'libtextsecure/websocket.js',
|
||||||
'libtextsecure/websocket-resources.js',
|
'libtextsecure/websocket-resources.js',
|
||||||
|
|
|
@ -5,15 +5,9 @@
|
||||||
;(function() {
|
;(function() {
|
||||||
window.axolotl = window.axolotl || {};
|
window.axolotl = window.axolotl || {};
|
||||||
window.axolotl.api = {
|
window.axolotl.api = {
|
||||||
getMyIdentifier: function() {
|
|
||||||
return textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
|
||||||
},
|
|
||||||
getMyRegistrationId: function() {
|
getMyRegistrationId: function() {
|
||||||
return textsecure.storage.getUnencrypted("registrationId");
|
return textsecure.storage.getUnencrypted("registrationId");
|
||||||
},
|
},
|
||||||
isIdentifierSane: function(identifier) {
|
|
||||||
return textsecure.utils.isNumberSane(identifier);
|
|
||||||
},
|
|
||||||
storage: {
|
storage: {
|
||||||
put: function(key, value) {
|
put: function(key, value) {
|
||||||
return textsecure.storage.putEncrypted(key, value);
|
return textsecure.storage.putEncrypted(key, value);
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
/*********************
|
/*********************
|
||||||
*** Group Storage ***
|
*** Group Storage ***
|
||||||
*********************/
|
*********************/
|
||||||
window.axolotl = window.axolotl || {};
|
window.textsecure = window.textsecure || {};
|
||||||
window.axolotl.storage = window.axolotl.storage || {};
|
window.textsecure.storage = window.textsecure.storage || {};
|
||||||
|
|
||||||
window.axolotl.storage.groups = {
|
window.textsecure.storage.groups = {
|
||||||
createNewGroup: function(numbers, groupId) {
|
createNewGroup: function(numbers, groupId) {
|
||||||
if (groupId !== undefined && axolotl.api.storage.get("group" + groupId) !== undefined)
|
if (groupId !== undefined && axolotl.api.storage.get("group" + groupId) !== undefined)
|
||||||
throw new Error("Tried to recreate group");
|
throw new Error("Tried to recreate group");
|
||||||
|
@ -31,12 +31,12 @@
|
||||||
while (groupId === undefined || axolotl.api.storage.get("group" + groupId) !== undefined)
|
while (groupId === undefined || axolotl.api.storage.get("group" + groupId) !== undefined)
|
||||||
groupId = getString(axolotl.crypto.getRandomBytes(16));
|
groupId = getString(axolotl.crypto.getRandomBytes(16));
|
||||||
|
|
||||||
var me = axolotl.api.getMyIdentifier();
|
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||||
var haveMe = false;
|
var haveMe = false;
|
||||||
var finalNumbers = [];
|
var finalNumbers = [];
|
||||||
for (var i in numbers) {
|
for (var i in numbers) {
|
||||||
var number = numbers[i];
|
var number = numbers[i];
|
||||||
if (!axolotl.api.isIdentifierSane(number))
|
if (!textsecure.utils.isNumberSane(number))
|
||||||
throw new Error("Invalid number in group");
|
throw new Error("Invalid number in group");
|
||||||
if (number == me)
|
if (number == me)
|
||||||
haveMe = true;
|
haveMe = true;
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
if (group === undefined)
|
if (group === undefined)
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
||||||
var me = axolotl.api.getMyIdentifier();
|
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||||
if (number == me)
|
if (number == me)
|
||||||
throw new Error("Cannot remove ourselves from a group, leave the group instead");
|
throw new Error("Cannot remove ourselves from a group, leave the group instead");
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
|
|
||||||
for (var i in numbers) {
|
for (var i in numbers) {
|
||||||
var number = numbers[i];
|
var number = numbers[i];
|
||||||
if (!axolotl.api.isIdentifierSane(number))
|
if (!textsecure.utils.isNumberSane(number))
|
||||||
throw new Error("Invalid number in set to add to group");
|
throw new Error("Invalid number in set to add to group");
|
||||||
if (group.numbers.indexOf(number) < 0) {
|
if (group.numbers.indexOf(number) < 0) {
|
||||||
group.numbers.push(number);
|
group.numbers.push(number);
|
||||||
|
@ -131,10 +131,4 @@
|
||||||
return needUpdate;
|
return needUpdate;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO: RM
|
|
||||||
window.textsecure = window.textsecure || {};
|
|
||||||
window.textsecure.storage = window.textsecure.storage || {};
|
|
||||||
window.textsecure.storage.groups = window.axolotl.storage.groups;
|
|
||||||
|
|
||||||
})();
|
})();
|
Loading…
Reference in a new issue