Mercurial > psgxs
changeset 21:e55b31f12f8c
Better handling of modify subscriptions.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 20 Oct 2010 00:26:45 +0200 |
parents | 957550e2d5a1 |
children | 0f42c9c8085a |
files | psgxs.js |
diffstat | 1 files changed, 18 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/psgxs.js +++ b/psgxs.js @@ -884,20 +884,30 @@ function onIq(stanza) { return makeError(response, errors.forbidden.n); var e = false; + var tags2 = []; for (i in subscriptions.tags) { - var jid = subscriptions.tags[i].getAttribute('jid'); - var subscription = subscriptions.tags[i].getAttribute('subscription'); + var tag = subscriptions.tags[i]; + var jid = tag.getAttribute('jid'); + var sub = tag.getAttribute('subscription'); + + if (sub == 'none' || sub == 'pending' || sub == 'subscribed' || sub == 'unconfigured') { + var set = storage.subscribe(nodeID, jid, sub); - var set = storage.subscribe(nodeID, jid, subscription); - if (typeof set == 'number') + if (typeof set == 'number') { + e = true; + tags2.push(tag); + } else { + // SECTION 8.8.4 + sendNotifs(jid, 'subscription', nodeID, {jid: jid, subscription: sub}); + } + } else { e = true; - else { - // SECTION 8.8.4 - sendNotifs(jid, 'subscription', nodeID, {jid: jid, subscription: subscription}); - subscriptions.tags.splice(i, 1); + tags2.push(tag); } } + subscriptions.tags = tags2; + if (e) return makeError(response, errors.owner.manage_subscriptions.modify.multiple_simultaneous_modifications.n, pubsub);