mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 10:58:19 +01:00
Move session-storage logic to storage/devices from axolotl_wrapper
This commit is contained in:
@@ -23,6 +23,28 @@
|
||||
window.textsecure = window.textsecure || {};
|
||||
window.textsecure.storage = window.textsecure.storage || {};
|
||||
|
||||
window.textsecure.storage.sessions = {
|
||||
getSessionsForNumber: function(encodedNumber) {
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber, true);
|
||||
if (device === undefined || device.sessions === undefined)
|
||||
return undefined;
|
||||
return device.sessions;
|
||||
},
|
||||
putSessionsForDevice: function(encodedNumber, sessions) {
|
||||
var device = textsecure.storage.devices.getDeviceObject(encodedNumber);
|
||||
if (device === undefined) {
|
||||
device = { encodedNumber: encodedNumber,
|
||||
//TODO: Remove this duplication
|
||||
identityKey: sessions.identityKey
|
||||
};
|
||||
}
|
||||
if (getString(device.identityKey) !== getString(sessions.identityKey))
|
||||
throw new Error("Tried to put session for device with changed identity key");
|
||||
device.sessions = sessions;
|
||||
return textsecure.storage.devices.saveDeviceObject(device);
|
||||
},
|
||||
};
|
||||
|
||||
window.textsecure.storage.devices = {
|
||||
saveDeviceObject: function(deviceObject) {
|
||||
return internalSaveDeviceObject(deviceObject, false);
|
||||
|
||||
Reference in New Issue
Block a user