# HG changeset patch # User Emmanuel Gil Peyrot # Date 1287527205 -7200 # Node ID e55b31f12f8c6e6ae21371b73f0f052e6a93e452 # Parent 957550e2d5a1af5300df4b671f8fa71eb896194e Better handling of modify subscriptions. diff --git a/psgxs.js b/psgxs.js --- 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);