Fixes #848 OTR doesn't start when cache_otr_key is set to true

This commit is contained in:
JC Brand 2017-04-20 10:04:33 +02:00
parent 15f6649ace
commit 39b3aa34d8
2 changed files with 15 additions and 12 deletions

View File

@ -13,6 +13,7 @@
- Bugfix: OTR meta-messages were being shown in HTML5 notifications. [jcbrand]
- CSS fix: Icon lock wasn't showing. [jcbrand]
- #842 Persistent muc room creation not working [jcbrand]
- #848 OTR doesn't start when `cache_otr_key` is set to `true`. [jcbrand]
- #849 `TypeError: _converse.i18n.locale_data is undefined` when reconnecting. [jcbrand]
## 3.0.1 (2017-04-04)

View File

@ -129,17 +129,20 @@
getSession: function (callback) {
var _converse = this.__super__._converse,
__ = _converse.__;
var instance_tag, saved_key;
var instance_tag, saved_key, encrypted_key;
if (_converse.cache_otr_key) {
instance_tag = this.get('otr_instance_tag');
saved_key = otr.DSA.parsePrivate(this.get('otr_priv_key'));
if (saved_key && instance_tag) {
this.trigger('showHelpMessages', [__('Re-establishing encrypted session')]);
callback({
'key': saved_key,
'instance_tag': instance_tag
});
return; // Our work is done here
encrypted_key = this.get('otr_priv_key');
if (_.isString(encrypted_key)) {
instance_tag = this.get('otr_instance_tag');
saved_key = otr.DSA.parsePrivate(encrypted_key)
if (saved_key && instance_tag) {
this.trigger('showHelpMessages', [__('Re-establishing encrypted session')]);
callback({
'key': saved_key,
'instance_tag': instance_tag
});
return; // Our work is done here
}
}
}
// We need to generate a new key and instance tag
@ -151,10 +154,9 @@
);
var that = this;
window.setTimeout(function () {
var instance_tag = otr.OTR.makeInstanceTag();
callback({
'key': that.generatePrivateKey(instance_tag),
'instance_tag': instance_tag
'instance_tag': otr.OTR.makeInstanceTag()
});
}, 500);
},