Browse Source

Fixes #577 Add a timeout config var for MAM

JC Brand 9 years ago
parent
commit
efa4a9ff23
3 changed files with 15 additions and 2 deletions
  1. 1 0
      docs/CHANGES.md
  2. 11 0
      docs/source/configuration.rst
  3. 3 2
      src/converse-core.js

+ 1 - 0
docs/CHANGES.md

@@ -13,6 +13,7 @@
 - #534 Updated Russian translation [badfiles]
 - #566 Do not steal the focus when the chatbox opens automatically [rlanvin]
 - #573 xgettext build error: `'javascript' unknown` [jcbrand]
+- #577 New config variable [message_archiving_timeout](https://conversejs.org/docs/html/configuration.html#message_archiving_timeout) [jcbrand]
 - #587 Fix issue when logging out with `auto_logout=true` [davec82]
 - #589 Save scroll position on minimize and restore it on maximize [rlanvin]
 - #592 Add random resource for `auto_login`, add method generateResource to generate random resource [davec82]

+ 11 - 0
docs/source/configuration.rst

@@ -500,6 +500,17 @@ This sets the default archiving preference. Valid values are ``never``, ``always
 ``roster`` means that only messages to and from JIDs in your roster will be
 archived. The other two values are self-explanatory.
 
+
+message_archiving_timeout
+-------------------------
+
+* Default:  ``8000``
+
+The amount of time (in milliseconds) to wait when requesting archived messages
+from the XMPP server.
+
+Used in conjunction with `message_archiving` and in context of `XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>`_.
+
 message_carbons
 ---------------
 

+ 3 - 2
src/converse-core.js

@@ -142,7 +142,7 @@
             errback = callback;
         }
         if (!converse.features.findWhere({'var': Strophe.NS.MAM})) {
-            throw new Error('This server does not support XEP-0313, Message Archive Management');
+            errback('This server does not support XEP-0313, Message Archive Management');
         }
         var queryid = converse.connection.getUniqueId();
         var attrs = {'type':'set'};
@@ -196,7 +196,7 @@
                 return false; // There's no callback, so no use in continuing this handler.
             }
         }, Strophe.NS.MAM);
-        converse.connection.sendIQ(stanza, null, errback);
+        converse.connection.sendIQ(stanza, null, errback, converse.message_archiving_timeout);
     };
 
 
@@ -370,6 +370,7 @@
             keepalive: false,
             locked_domain: undefined,
             message_archiving: 'never', // Supported values are 'always', 'never', 'roster' (See https://xmpp.org/extensions/xep-0313.html#prefs )
+            message_archiving_timeout: 8000, // The amount of time (in milliseconds) to wait before aborting a MAM (XEP-0313) request
             message_carbons: false, // Support for XEP-280
             no_trimming: false, // Set to true for phantomjs tests (where browser apparently has no width)
             password: undefined,