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