Move MAM specific code to converse-mam.js

This commit is contained in:
JC Brand 2017-02-28 22:17:28 +01:00
parent dc8cbc6104
commit a3407bb98b
3 changed files with 16 additions and 13 deletions

View File

@ -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('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('ROSTERX', 'http://jabber.org/protocol/rosterx');
Strophe.addNamespace('XFORM', 'jabber:x:data');
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
Strophe.addNamespace('HINTS', 'urn:xmpp:hints');
Strophe.addNamespace('PUBSUB', 'http://jabber.org/protocol/pubsub');
Strophe.addNamespace('DELAY', 'urn:xmpp:delay');
// Instance level constants
this.TIMEOUTS = { // Set as module attr so that we can override in tests.

View File

@ -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.
*

View File

@ -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;