A few fixes after some "real world" tests.
This commit is contained in:
parent
330b1434bd
commit
96396fdc6e
55
converse.js
55
converse.js
@ -3520,7 +3520,7 @@
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* (String) message - Optional message to send to the person being authorized
|
* (String) message - Optional message to send to the person being authorized
|
||||||
*/
|
*/
|
||||||
var pres = $pres({to: jid, type: "subscribed"});
|
var pres = $pres({to: this.get('jid'), type: "subscribed"});
|
||||||
if (message && message !== "") {
|
if (message && message !== "") {
|
||||||
pres.c("status").t(message);
|
pres.c("status").t(message);
|
||||||
}
|
}
|
||||||
@ -3529,14 +3529,15 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
removeResource: function (resource) {
|
removeResource: function (resource) {
|
||||||
var resources = item.get('resources');
|
var resources = this.get('resources'), idx;
|
||||||
var idx = _.indexOf(resources, resource);
|
if (resource) {
|
||||||
if (idx !== -1) {
|
idx = _.indexOf(resources, resource);
|
||||||
resources.splice(idx, 1);
|
if (idx !== -1) {
|
||||||
item.save({'resources': resources});
|
resources.splice(idx, 1);
|
||||||
return resources.length;
|
this.save({'resources': resources});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return resources.length;
|
||||||
},
|
},
|
||||||
|
|
||||||
removeFromRoster: function (callback) {
|
removeFromRoster: function (callback) {
|
||||||
@ -3932,7 +3933,16 @@
|
|||||||
}, {sort: false});
|
}, {sort: false});
|
||||||
} else {
|
} else {
|
||||||
if ((subscription === 'none') && (ask === null)) {
|
if ((subscription === 'none') && (ask === null)) {
|
||||||
contact.destroy(); // This user is no longer in our roster
|
// When making a contact request, a roster push is
|
||||||
|
// received with the user being requested with
|
||||||
|
/* <iq xmlns="jabber:client" type="set" id="lx799">
|
||||||
|
<query xmlns="jabber:iq:roster" ver="30">
|
||||||
|
<item jid="jc@opkode.com" name="jc@opkode.com" subscription="none"/>
|
||||||
|
</query>
|
||||||
|
</iq>
|
||||||
|
*/
|
||||||
|
return; // XXX: figure out what's going on here.
|
||||||
|
// contact.destroy(); // This user is no longer in our roster
|
||||||
} else {
|
} else {
|
||||||
// We only find out about requesting contacts via the
|
// We only find out about requesting contacts via the
|
||||||
// presence handler, so if we receive a contact
|
// presence handler, so if we receive a contact
|
||||||
@ -3983,7 +3993,7 @@
|
|||||||
bare_jid, this.createContactFromVCard.bind(this),
|
bare_jid, this.createContactFromVCard.bind(this),
|
||||||
function (iq, jid) {
|
function (iq, jid) {
|
||||||
converse.log("Error while retrieving vcard for "+jid);
|
converse.log("Error while retrieving vcard for "+jid);
|
||||||
this.createContactFromVCard.apply(this, iq, jid);
|
this.createContactFromVCard.call(this, iq, jid);
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -3997,44 +4007,33 @@
|
|||||||
var jid = presence.getAttribute('from'),
|
var jid = presence.getAttribute('from'),
|
||||||
bare_jid = Strophe.getBareJidFromJid(jid),
|
bare_jid = Strophe.getBareJidFromJid(jid),
|
||||||
resource = Strophe.getResourceFromJid(jid),
|
resource = Strophe.getResourceFromJid(jid),
|
||||||
$show = $presence.find('show'),
|
chat_status = $presence.find('show').text() || 'online',
|
||||||
chat_status = $show.text() || 'online',
|
|
||||||
status_message = $presence.find('status'),
|
status_message = $presence.find('status'),
|
||||||
contact = this.get(bare_jid);
|
contact = this.get(bare_jid);
|
||||||
|
|
||||||
if (this.isSelf(bare_jid)) {
|
if (this.isSelf(bare_jid)) {
|
||||||
if ((converse.connection.jid !== jid)&&(presence_type !== 'unavailable')) {
|
if ((converse.connection.jid !== jid)&&(presence_type !== 'unavailable')) {
|
||||||
// Another resource has changed it's status, we'll update ours as well.
|
// Another resource has changed it's status, we'll update ours as well.
|
||||||
converse.xmppstatus.save({'status': chat_status});
|
converse.xmppstatus.save({'status': chat_status});
|
||||||
}
|
}
|
||||||
return true;
|
return;
|
||||||
} else if (($presence.find('x').attr('xmlns') || '').indexOf(Strophe.NS.MUC) === 0) {
|
} else if (($presence.find('x').attr('xmlns') || '').indexOf(Strophe.NS.MUC) === 0) {
|
||||||
return true; // Ignore MUC
|
return; // Ignore MUC
|
||||||
}
|
}
|
||||||
if (contact && (status_message.text() != contact.get('status'))) {
|
if (contact && (status_message.text() != contact.get('status'))) {
|
||||||
contact.save({'status': status_message.text()});
|
contact.save({'status': status_message.text()});
|
||||||
}
|
}
|
||||||
if ((presence_type === 'subscribed') || (presence_type === 'unsubscribe')) {
|
if ((presence_type === 'subscribed') || (presence_type === 'unsubscribe')) {
|
||||||
return true;
|
return;
|
||||||
} else if (presence_type === 'subscribe') {
|
} else if (presence_type === 'subscribe') {
|
||||||
this.handleIncomingSubscription(jid);
|
this.handleIncomingSubscription(jid);
|
||||||
} else if (presence_type === 'unsubscribed') {
|
} else if (presence_type === 'unsubscribed') {
|
||||||
this.unsubscribe(bare_jid);
|
this.unsubscribe(bare_jid);
|
||||||
} else if (presence_type === 'unavailable') {
|
} else if (presence_type === 'unavailable' && contact) {
|
||||||
if (contact) {
|
contact.save({'chat_status': (contact.removeResource(resource) === 0) ? "offline" : chat_status});
|
||||||
if (contact.removeResource(bare_jid, resource) === 0) {
|
} else if (contact) { // presence_type is undefined
|
||||||
chat_status = "offline";
|
|
||||||
}
|
|
||||||
if (chat_status) {
|
|
||||||
contact.save({'chat_status': chat_status});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (contact) {
|
|
||||||
// presence_type is undefined
|
|
||||||
this.addResource(bare_jid, resource);
|
this.addResource(bare_jid, resource);
|
||||||
contact.save({'chat_status': chat_status});
|
contact.save({'chat_status': chat_status});
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user