Don't save device objects to disk

Generate them from session and identity data. Save/delete pending prekey
data in an in-memory store and attach it to outgoing device objects.
This commit is contained in:
lilia 2015-04-21 20:05:40 -07:00
parent f18795a253
commit 43d6efcd9e
3 changed files with 85 additions and 213 deletions

View file

@ -198,19 +198,7 @@
contact.fetch().always(function() {
var sessions = contact.get('sessions') || {};
sessions[deviceId] = record;
contact.save({sessions: sessions}).always(function() {
resolve(textsecure.storage.devices.getDeviceObject(encodedNumber).then(function(device) {
if (device === undefined) {
return textsecure.storage.axolotl.getIdentityKey(number).then(function(identityKey) {
device = { encodedNumber: encodedNumber,
//TODO: Remove this duplication
identityKey: identityKey
};
return textsecure.storage.devices.saveDeviceObject(device);
});
}
}));
});
contact.save({sessions: sessions}).always(resolve);
});
});
},