Ensure the unique object id is stored in the object to facilitate deleting it later.

pull/6/head
sachaaaaa 7 years ago
parent 2f562ce9e1
commit bb65115d7d

@ -48,11 +48,11 @@ const migrations = [
transaction.db.createObjectStore('signedPreKeys');
transaction.db.createObjectStore('items');
const contactPreKeys = transaction.db.createObjectStore('contactPreKeys', { autoIncrement : true });
contactPreKeys.createIndex('publicKeyString', 'publicKeyString', { unique: false });
const contactPreKeys = transaction.db.createObjectStore('contactPreKeys', { keyPath: 'id', autoIncrement : true });
contactPreKeys.createIndex('identityKeyString', 'identityKeyString', { unique: false });
const contactSignedPreKeys = transaction.db.createObjectStore('contactSignedPreKeys', { autoIncrement : true });
contactSignedPreKeys.createIndex('publicKeyString', 'publicKeyString', { unique: false });
const contactSignedPreKeys = transaction.db.createObjectStore('contactSignedPreKeys', { keyPath: 'id', autoIncrement : true });
contactSignedPreKeys.createIndex('identityKeyString', 'identityKeyString', { unique: false });
window.log.info('creating debug log');
transaction.db.createObjectStore('debug');

@ -224,15 +224,16 @@
});
},
loadContactPreKey(pubKey) {
const prekey = new ContactPreKey({ id: pubKey });
const prekey = new ContactPreKey({ identityKeyString: pubKey });
return new Promise(resolve => {
prekey.fetch().then(
() => {
window.log.info('Successfully fetched contact prekey:', pubKey);
resolve({
id: prekey.get('id'),
keyId: prekey.get('keyId'),
publicKey: prekey.get('publicKey'),
identityKey: prekey.get('identityKey'),
identityKeyString: prekey.get('identityKeyString'),
});
},
() => {
@ -245,7 +246,7 @@
storeContactPreKey(pubKey, preKey) {
const prekey = new ContactPreKey({
// id: (autoincrement)
publicKeyString: pubKey,
identityKeyString: pubKey,
publicKey: preKey.publicKey,
keyId: preKey.keyId,
});
@ -320,7 +321,7 @@
});
},
loadContactSignedPreKey(pubKey) {
const prekey = new ContactSignedPreKey({ id: pubKey });
const prekey = new ContactSignedPreKey({ identityKeyString: pubKey });
return new Promise(resolve => {
prekey
.fetch()
@ -330,8 +331,8 @@
prekey.get('id')
);
resolve({
id: preKey.get('id'),
publicKeyString: preKey.get('publicKeyString'),
id: prekey.get('id'),
identityKeyString: prekey.get('identityKeyString'),
publicKey: prekey.get('publicKey'),
signature: prekey.get('signature'),
created_at: prekey.get('created_at'),
@ -383,7 +384,7 @@
storeContactSignedPreKey(pubKey, signedPreKey) {
const prekey = new ContactSignedPreKey({
// id: (autoincrement)
publicKeyString: pubKey,
identityKeyString: pubKey,
keyId: signedPreKey.keyId,
publicKey: signedPreKey.publicKey,
signature: signedPreKey.signature,

@ -78,7 +78,7 @@
}),
];
for (let keyId = 0; keyId < 100; keyId += 1) {
for (let keyId = 0; keyId < 10; keyId += 1) {
promises.push(
libsignal.KeyHelper.generatePreKey(keyId)
.then((preKey) => {
@ -86,7 +86,7 @@
}),
)
}
Promise.all(promises).then(
return Promise.all(promises).then(
log.info("Added mock contact with pubkey " + pubKey)
);
});

Loading…
Cancel
Save