Don't trigger OMEMOInitialized if something went wrong.

This commit is contained in:
JC Brand 2019-03-31 12:01:19 +02:00
parent dd0c0b6c56
commit 337e267594
2 changed files with 26 additions and 11 deletions

14
dist/converse.js vendored
View File

@ -57001,13 +57001,13 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
this.fetch({
'success': () => {
if (!_converse.omemo_store.get('device_id')) {
this.generateBundle().then(resolve).catch(resolve);
this.generateBundle().then(resolve).catch(reject);
} else {
resolve();
}
},
'error': () => {
this.generateBundle().then(resolve).catch(resolve);
this.generateBundle().then(resolve).catch(reject);
}
});
});
@ -57350,15 +57350,25 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
try {
await fetchOwnDevices();
await restoreOMEMOSession();
await _converse.omemo_store.publishBundle();
} catch (e) {
_converse.log("Could not initialize OMEMO support", Strophe.LogLevel.ERROR);
_converse.log(e, Strophe.LogLevel.ERROR);
return;
}
/**
* Triggered once OMEMO support has been initialized
* @event _converse#OMEMOInitialized
* @example _converse.api.listen.on('OMEMOInitialized', () => { ... });
*/
_converse.api.trigger('OMEMOInitialized');
}

View File

@ -844,7 +844,6 @@ converse.plugins.add('converse-omemo', {
* generated integer between 1 and 2^31 - 1.
*/
const identity_keypair = await libsignal.KeyHelper.generateIdentityKeyPair();
const bundle = {},
identity_key = u.arrayBufferToBase64(identity_keypair.pubKey),
device_id = generateDeviceID();
@ -882,13 +881,13 @@ converse.plugins.add('converse-omemo', {
this.fetch({
'success': () => {
if (!_converse.omemo_store.get('device_id')) {
this.generateBundle().then(resolve).catch(resolve);
this.generateBundle().then(resolve).catch(reject);
} else {
resolve();
}
},
'error': () => {
this.generateBundle().then(resolve).catch(resolve);
this.generateBundle().then(resolve).catch(reject);
}
});
});
@ -1160,9 +1159,15 @@ converse.plugins.add('converse-omemo', {
id = `converse.devicelists-${_converse.bare_jid}`;
_converse.devicelists.browserStorage = new Backbone.BrowserStorage[storage](id);
try {
await fetchOwnDevices();
await restoreOMEMOSession();
await _converse.omemo_store.publishBundle();
} catch (e) {
_converse.log("Could not initialize OMEMO support", Strophe.LogLevel.ERROR);
_converse.log(e, Strophe.LogLevel.ERROR);
return;
}
/**
* Triggered once OMEMO support has been initialized
* @event _converse#OMEMOInitialized