Commit c9cf028c authored by JC Brand's avatar JC Brand

Improved the presence handling when auto-subscribe is on.

parent 88e0cb5b
...@@ -911,6 +911,8 @@ ...@@ -911,6 +911,8 @@
}, this)); }, this));
return; return;
} }
} else if (!view.isVisible()) {
this.showChat(bare_jid);
} }
view.messageReceived(message); view.messageReceived(message);
xmppchat.roster.addResource(bare_jid, resource); xmppchat.roster.addResource(bare_jid, resource);
...@@ -1219,13 +1221,24 @@ ...@@ -1219,13 +1221,24 @@
item = this.getItem(bare_jid); item = this.getItem(bare_jid);
if (xmppchat.auto_subscribe) { if (xmppchat.auto_subscribe) {
//XXX: Probably need to get fullname support here... if ((!item) || (item.get('subscription') != 'to')) {
xmppchat.connection.roster.authorize(bare_jid); if (xmppchat.connection.roster.get(jid)) {
if (!(item) || (item.get('subscription') == 'none')) { $.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(jid), $.proxy(function (data) {
// Subscribe back xmppchat.connection.roster.update(jid, data.fullname, [], function (iq) {
xmppchat.connection.roster.add(jid, name, [], function (iq) { xmppchat.connection.roster.authorize(bare_jid);
xmppchat.connection.roster.subscribe(jid); xmppchat.connection.roster.subscribe(jid);
}); });
}, this));
} else {
$.getJSON(portal_url + "/xmpp-userinfo?user_id=" + Strophe.getNodeFromJid(jid), $.proxy(function (data) {
xmppchat.connection.roster.add(jid, data.fullname, [], function (iq) {
xmppchat.connection.roster.authorize(bare_jid);
xmppchat.connection.roster.subscribe(jid);
});
}, this));
}
} else {
xmppchat.connection.roster.authorize(bare_jid);
} }
} else { } else {
if ((item) && (item.get('subscription') != 'none')) { if ((item) && (item.get('subscription') != 'none')) {
...@@ -1269,7 +1282,9 @@ ...@@ -1269,7 +1282,9 @@
} else { } else {
if (this.removeResource(bare_jid, resource) === 0) { if (this.removeResource(bare_jid, resource) === 0) {
model = this.getItem(bare_jid); model = this.getItem(bare_jid);
model.set({'presence_type': presence_type}); if (model) {
model.set({'presence_type': presence_type});
}
} }
} }
} }
......
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