2
0
Эх сурвалжийг харах

Handle IQ timeouts

* converse-muc: Handle timeout while fetching affiliation list
* converse-omemo: Handle IQ timeout
JC Brand 6 жил өмнө
parent
commit
ea123e9713

+ 6 - 2
src/converse-omemo.js

@@ -1004,8 +1004,12 @@ converse.plugins.add('converse-omemo', {
                     try {
                     try {
                         ids = await this.fetchDevicesFromServer()
                         ids = await this.fetchDevicesFromServer()
                     } catch (e) {
                     } catch (e) {
-                        _converse.log(`Could not fetch devices for ${this.get('jid')}`);
-                        _converse.log(e, Strophe.LogLevel.ERROR);
+                        if (e === null) {
+                            _converse.log(`Timeout error while fetching devices for ${this.get('jid')}`, Strophe.LogLevel.ERROR);
+                        } else {
+                            _converse.log(`Could not fetch devices for ${this.get('jid')}`, Strophe.LogLevel.ERROR);
+                            _converse.log(e, Strophe.LogLevel.ERROR);
+                        }
                         this.destroy();
                         this.destroy();
                     }
                     }
                     if (this.get('jid') === _converse.bare_jid) {
                     if (this.get('jid') === _converse.bare_jid) {

+ 8 - 1
src/headless/converse-muc.js

@@ -1111,7 +1111,14 @@ converse.plugins.add('converse-muc', {
                     .c("query", {xmlns: Strophe.NS.MUC_ADMIN})
                     .c("query", {xmlns: Strophe.NS.MUC_ADMIN})
                         .c("item", {'affiliation': affiliation});
                         .c("item", {'affiliation': affiliation});
                 const result = await _converse.api.sendIQ(iq, null, false);
                 const result = await _converse.api.sendIQ(iq, null, false);
-                if (result.getAttribute('type') === 'error') {
+                if (result === null) {
+                    const err_msg = `Error: timeout while fetching ${affiliation} list for MUC ${this.get('jid')}`;
+                    const err = new Error(err_msg);
+                    _converse.log(err_msg, Strophe.LogLevel.WARN);
+                    _converse.log(result, Strophe.LogLevel.WARN);
+                    return err;
+                }
+                if (u.isErrorStanza(result)) {
                     const err_msg = `Error: not allowed to fetch ${affiliation} list for MUC ${this.get('jid')}`;
                     const err_msg = `Error: not allowed to fetch ${affiliation} list for MUC ${this.get('jid')}`;
                     const err = new Error(err_msg);
                     const err = new Error(err_msg);
                     _converse.log(err_msg, Strophe.LogLevel.WARN);
                     _converse.log(err_msg, Strophe.LogLevel.WARN);