Преглед изворни кода

Move MAM specific code to converse-mam.js

JC Brand пре 8 година
родитељ
комит
a3407bb98b
3 измењених фајлова са 16 додато и 13 уклоњено
  1. 4 4
      src/converse-core.js
  2. 11 1
      src/converse-mam.js
  3. 1 8
      src/converse-muc.js

+ 4 - 4
src/converse-core.js

@@ -181,12 +181,12 @@
         Strophe.addNamespace('CARBONS', 'urn:xmpp:carbons:2');
         Strophe.addNamespace('CHATSTATES', 'http://jabber.org/protocol/chatstates');
         Strophe.addNamespace('CSI', 'urn:xmpp:csi:0');
-        Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
-        Strophe.addNamespace('XFORM', 'jabber:x:data');
-        Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
+        Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
         Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
+        Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
         Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
-        Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
+        Strophe.addNamespace('ROSTERX', 'http://jabber.org/protocol/rosterx');
+        Strophe.addNamespace('XFORM', 'jabber:x:data');
 
         // Instance level constants
         this.TIMEOUTS = { // Set as module attr so that we can override in tests.

+ 11 - 1
src/converse-mam.js

@@ -30,7 +30,6 @@
     Strophe.addNamespace('MAM', 'urn:xmpp:mam:0');
     Strophe.addNamespace('RSM', 'http://jabber.org/protocol/rsm');
 
-
     converse.plugins.add('converse-mam', {
 
         overrides: {
@@ -137,6 +136,17 @@
                     return result;
                 },
 
+                handleMUCMessage: function (stanza) {
+                    /* MAM (message archive management XEP-0313) messages are
+                     * ignored, since they're handled separately.
+                     */
+                    var is_mam = $(stanza).find('[xmlns="'+Strophe.NS.MAM+'"]').length > 0;
+                    if (is_mam) {
+                        return true;
+                    }
+                    return this.__super__.handleMUCMessage.apply(this, arguments);
+                },
+
                 fetchArchivedMessages: function (options) {
                     /* Fetch archived chat messages from the XMPP server.
                      *

+ 1 - 8
src/converse-muc.js

@@ -1020,17 +1020,10 @@
 
                 handleMUCMessage: function (stanza) {
                     /* Handler for all MUC messages sent to this chat room.
-                     *
-                     * MAM (message archive management XEP-0313) messages are
-                     * ignored, since they're handled separately.
                      *
                      * Parameters:
                      *  (XMLElement) stanza: The message stanza.
                      */
-                    var is_mam = $(stanza).find('[xmlns="'+Strophe.NS.MAM+'"]').length > 0;
-                    if (is_mam) {
-                        return true;
-                    }
                     var configuration_changed = stanza.querySelector("status[code='104']");
                     var logging_enabled = stanza.querySelector("status[code='170']");
                     var logging_disabled = stanza.querySelector("status[code='171']");
@@ -1374,7 +1367,7 @@
                             _.each(iq.querySelectorAll('feature'), function (field) {
                                 var fieldname = field.getAttribute('var');
                                 if (!fieldname.startsWith('muc_')) {
-                                    if (fieldname === 'urn:xmpp:mam:0') {
+                                    if (fieldname === Strophe.NS.MAM) {
                                         features.mam_enabled = true;
                                     }
                                     return;