Remove axolotl.storage usage from libtextsecure
This commit is contained in:
parent
b790f82849
commit
e2e06b2d3c
3 changed files with 28 additions and 28 deletions
|
@ -25,11 +25,11 @@
|
|||
|
||||
window.textsecure.storage.groups = {
|
||||
createNewGroup: function(numbers, groupId) {
|
||||
if (groupId !== undefined && axolotl.api.storage.get("group" + groupId) !== undefined)
|
||||
if (groupId !== undefined && textsecure.storage.getEncrypted("group" + groupId) !== undefined)
|
||||
throw new Error("Tried to recreate group");
|
||||
|
||||
while (groupId === undefined || axolotl.api.storage.get("group" + groupId) !== undefined)
|
||||
groupId = getString(axolotl.crypto.getRandomBytes(16));
|
||||
while (groupId === undefined || textsecure.storage.getEncrypted("group" + groupId) !== undefined)
|
||||
groupId = getString(textsecure.crypto.getRandomBytes(16));
|
||||
|
||||
var me = textsecure.utils.unencodeNumber(textsecure.storage.getUnencrypted("number_id"))[0];
|
||||
var haveMe = false;
|
||||
|
@ -51,13 +51,13 @@
|
|||
for (var i in finalNumbers)
|
||||
groupObject.numberRegistrationIds[finalNumbers[i]] = {};
|
||||
|
||||
axolotl.api.storage.put("group" + groupId, groupObject);
|
||||
textsecure.storage.putEncrypted("group" + groupId, groupObject);
|
||||
|
||||
return {id: groupId, numbers: finalNumbers};
|
||||
},
|
||||
|
||||
getNumbers: function(groupId) {
|
||||
var group = axolotl.api.storage.get("group" + groupId);
|
||||
var group = textsecure.storage.getEncrypted("group" + groupId);
|
||||
if (group === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
|||
},
|
||||
|
||||
removeNumber: function(groupId, number) {
|
||||
var group = axolotl.api.storage.get("group" + groupId);
|
||||
var group = textsecure.storage.getEncrypted("group" + groupId);
|
||||
if (group === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -77,14 +77,14 @@
|
|||
if (i > -1) {
|
||||
group.numbers.slice(i, 1);
|
||||
delete group.numberRegistrationIds[number];
|
||||
axolotl.api.storage.put("group" + groupId, group);
|
||||
textsecure.storage.putEncrypted("group" + groupId, group);
|
||||
}
|
||||
|
||||
return group.numbers;
|
||||
},
|
||||
|
||||
addNumbers: function(groupId, numbers) {
|
||||
var group = axolotl.api.storage.get("group" + groupId);
|
||||
var group = textsecure.storage.getEncrypted("group" + groupId);
|
||||
if (group === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -98,16 +98,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
axolotl.api.storage.put("group" + groupId, group);
|
||||
textsecure.storage.putEncrypted("group" + groupId, group);
|
||||
return group.numbers;
|
||||
},
|
||||
|
||||
deleteGroup: function(groupId) {
|
||||
axolotl.api.storage.remove("group" + groupId);
|
||||
textsecure.storage.removeEncrypted("group" + groupId);
|
||||
},
|
||||
|
||||
getGroup: function(groupId) {
|
||||
var group = axolotl.api.storage.get("group" + groupId);
|
||||
var group = textsecure.storage.getEncrypted("group" + groupId);
|
||||
if (group === undefined)
|
||||
return undefined;
|
||||
|
||||
|
@ -115,7 +115,7 @@
|
|||
},
|
||||
|
||||
needUpdateByDeviceRegistrationId: function(groupId, number, encodedNumber, registrationId) {
|
||||
var group = axolotl.api.storage.get("group" + groupId);
|
||||
var group = textsecure.storage.getEncrypted("group" + groupId);
|
||||
if (group === undefined)
|
||||
throw new Error("Unknown group for device registration id");
|
||||
|
||||
|
@ -127,7 +127,7 @@
|
|||
|
||||
var needUpdate = group.numberRegistrationIds[number][encodedNumber] !== undefined;
|
||||
group.numberRegistrationIds[number][encodedNumber] = registrationId;
|
||||
axolotl.api.storage.put("group" + groupId, group);
|
||||
textsecure.storage.putEncrypted("group" + groupId, group);
|
||||
return needUpdate;
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue