Commit 1f82b7df authored by JC Brand's avatar JC Brand

Create utils method `isSameBareJID`. Refs: #894

parent ad06c2b9
......@@ -1020,7 +1020,7 @@
},
isSelf: function (jid) {
return (Strophe.getBareJidFromJid(jid) === Strophe.getBareJidFromJid(_converse.connection.jid));
return utils.isSameBareJID(jid, _converse.connection.jid);
},
addAndSubscribe: function (jid, name, groups, message, attributes) {
......@@ -1510,7 +1510,7 @@
*/
// TODO: we can likely just reuse "onMessage" below
var from_jid = Strophe.getBareJidFromJid(message.getAttribute('from'));
if (from_jid === _converse.bare_jid) {
if (utils.isSameBareJID(from_jid, _converse.bare_jid)) {
return true;
}
// Get chat box, but only create a new one when the message has a body.
......
......@@ -1717,7 +1717,7 @@
var item = sizzle('x[xmlns="'+Strophe.NS.MUC_USER+'"] item', pres).pop();
if (_.isNil(item)) { return; }
var jid = item.getAttribute('jid');
if (Strophe.getBareJidFromJid(jid).toLowerCase() === _converse.bare_jid.toLowerCase()) {
if (utils.isSameBareJID(jid, _converse.bare_jid)) {
var affiliation = item.getAttribute('affiliation');
var role = item.getAttribute('role');
if (affiliation) {
......
......@@ -227,6 +227,11 @@
}
},
isSameBareJID: function (jid1, jid2) {
return Strophe.getBareJidFromJid(jid1).toLowerCase() ===
Strophe.getBareJidFromJid(jid2).toLowerCase();
},
isNewMessage: function (message) {
/* Given a stanza, determine whether it's a new
* message, i.e. not a MAM archived one.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment