Commit 7279f08a authored by JC Brand's avatar JC Brand

Update to newer skeletor which can return a promise on `create`

parent 7d7c41a1
...@@ -16059,8 +16059,8 @@ ...@@ -16059,8 +16059,8 @@
"dev": true "dev": true
}, },
"skeletor.js": { "skeletor.js": {
"version": "github:skeletorjs/skeletor#5a95708a5fdec9029fc493c1df4bca337803f124", "version": "github:skeletorjs/skeletor#dea2d5791ee894493e30b92662c953efec0e58f6",
"from": "github:skeletorjs/skeletor#5a95708a5fdec9029fc493c1df4bca337803f124", "from": "github:skeletorjs/skeletor#dea2d5791ee894493e30b92662c953efec0e58f6",
"requires": { "requires": {
"lodash": "^4.17.14" "lodash": "^4.17.14"
} }
......
...@@ -323,7 +323,7 @@ converse.plugins.add('converse-omemo', { ...@@ -323,7 +323,7 @@ converse.plugins.add('converse-omemo', {
this.save('omemo_supported', true); this.save('omemo_supported', true);
let device = devicelist.get(encrypted.device_id); let device = devicelist.get(encrypted.device_id);
if (!device) { if (!device) {
device = devicelist.devices.create({'id': encrypted.device_id, 'jid': attrs.from}); device = await devicelist.devices.create({'id': encrypted.device_id, 'jid': attrs.from}, {'promise': true});
} }
if (encrypted.payload) { if (encrypted.payload) {
const key = key_and_tag.slice(0, 16); const key = key_and_tag.slice(0, 16);
...@@ -887,12 +887,7 @@ converse.plugins.add('converse-omemo', { ...@@ -887,12 +887,7 @@ converse.plugins.add('converse-omemo', {
const keys = await Promise.all(_.range(0, _converse.NUM_PREKEYS).map(id => libsignal.KeyHelper.generatePreKey(id))); const keys = await Promise.all(_.range(0, _converse.NUM_PREKEYS).map(id => libsignal.KeyHelper.generatePreKey(id)));
keys.forEach(k => _converse.omemo_store.storePreKey(k.keyId, k.keyPair)); keys.forEach(k => _converse.omemo_store.storePreKey(k.keyId, k.keyPair));
const devicelist = _converse.devicelists.get(_converse.bare_jid); const devicelist = _converse.devicelists.get(_converse.bare_jid);
const device = await new Promise((success, error) => { const device = await devicelist.devices.create({'id': bundle.device_id, 'jid': _converse.bare_jid}, {'promise': true});
devicelist.devices.create(
{'id': bundle.device_id, 'jid': _converse.bare_jid},
{success, 'error': (m, e) => error(e)}
);
});
const marshalled_keys = keys.map(k => ({'id': k.keyId, 'key': u.arrayBufferToBase64(k.keyPair.pubKey)})); const marshalled_keys = keys.map(k => ({'id': k.keyId, 'key': u.arrayBufferToBase64(k.keyPair.pubKey)}));
bundle['prekeys'] = marshalled_keys; bundle['prekeys'] = marshalled_keys;
device.save('bundle', bundle); device.save('bundle', bundle);
...@@ -1054,11 +1049,9 @@ converse.plugins.add('converse-omemo', { ...@@ -1054,11 +1049,9 @@ converse.plugins.add('converse-omemo', {
} }
const selector = `list[xmlns="${Strophe.NS.OMEMO}"] device`; const selector = `list[xmlns="${Strophe.NS.OMEMO}"] device`;
const device_ids = sizzle(selector, iq).map(d => d.getAttribute('id')); const device_ids = sizzle(selector, iq).map(d => d.getAttribute('id'));
const deviceFactory = (id, success, error) => { await Promise.all(
this.devices.create({id, 'jid': this.get('jid')}, {success, 'error': (m, e) => error(e)}) device_ids.map(id => this.devices.create({id, 'jid': this.get('jid')}, {'promise': true}))
} );
const promises = device_ids.map(id => new Promise((resolve, reject) => deviceFactory(id, resolve, reject)));
await Promise.all(promises);
return device_ids; return device_ids;
}, },
...@@ -1108,7 +1101,7 @@ converse.plugins.add('converse-omemo', { ...@@ -1108,7 +1101,7 @@ converse.plugins.add('converse-omemo', {
if (own_devicelist) { if (own_devicelist) {
own_devicelist.fetchDevices(); own_devicelist.fetchDevices();
} else { } else {
own_devicelist = _converse.devicelists.create({'jid': _converse.bare_jid}); own_devicelist = await _converse.devicelists.create({'jid': _converse.bare_jid}, {'promise': true});
} }
return own_devicelist._devices_promise; return own_devicelist._devices_promise;
} }
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
}, },
"gitHead": "9641dcdc820e029b05930479c242d2b707bbe8e2", "gitHead": "9641dcdc820e029b05930479c242d2b707bbe8e2",
"devDependencies": { "devDependencies": {
"skeletor.js": "skeletorjs/skeletor#5a95708a5fdec9029fc493c1df4bca337803f124", "skeletor.js": "skeletorjs/skeletor#dea2d5791ee894493e30b92662c953efec0e58f6",
"filesize": "^4.1.2", "filesize": "^4.1.2",
"jed": "1.1.1", "jed": "1.1.1",
"localforage": "^1.7.3", "localforage": "^1.7.3",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment