Mercurial > psgxs
comparison psgxs.js @ 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 |
comparison
equal
deleted
inserted
replaced
20:957550e2d5a1 | 21:e55b31f12f8c |
---|---|
882 var affil = storage.getAffiliation(toBareJID(to), nodeID); | 882 var affil = storage.getAffiliation(toBareJID(to), nodeID); |
883 if (affil != 'super-owner' && affil != 'owner') | 883 if (affil != 'super-owner' && affil != 'owner') |
884 return makeError(response, errors.forbidden.n); | 884 return makeError(response, errors.forbidden.n); |
885 | 885 |
886 var e = false; | 886 var e = false; |
887 var tags2 = []; | |
887 for (i in subscriptions.tags) { | 888 for (i in subscriptions.tags) { |
888 var jid = subscriptions.tags[i].getAttribute('jid'); | 889 var tag = subscriptions.tags[i]; |
889 var subscription = subscriptions.tags[i].getAttribute('subscription'); | 890 var jid = tag.getAttribute('jid'); |
890 | 891 var sub = tag.getAttribute('subscription'); |
891 var set = storage.subscribe(nodeID, jid, subscription); | 892 |
892 if (typeof set == 'number') | 893 if (sub == 'none' || sub == 'pending' || sub == 'subscribed' || sub == 'unconfigured') { |
894 var set = storage.subscribe(nodeID, jid, sub); | |
895 | |
896 if (typeof set == 'number') { | |
897 e = true; | |
898 tags2.push(tag); | |
899 } else { | |
900 // SECTION 8.8.4 | |
901 sendNotifs(jid, 'subscription', nodeID, {jid: jid, subscription: sub}); | |
902 } | |
903 } else { | |
893 e = true; | 904 e = true; |
894 else { | 905 tags2.push(tag); |
895 // SECTION 8.8.4 | |
896 sendNotifs(jid, 'subscription', nodeID, {jid: jid, subscription: subscription}); | |
897 subscriptions.tags.splice(i, 1); | |
898 } | 906 } |
899 } | 907 } |
908 | |
909 subscriptions.tags = tags2; | |
900 | 910 |
901 if (e) | 911 if (e) |
902 return makeError(response, errors.owner.manage_subscriptions.modify.multiple_simultaneous_modifications.n, pubsub); | 912 return makeError(response, errors.owner.manage_subscriptions.modify.multiple_simultaneous_modifications.n, pubsub); |
903 | 913 |
904 // SECTION 8.9.2 | 914 // SECTION 8.9.2 |