changeset 18:75625771e410

Send subscription request only if node access_model is authorize.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 19 Oct 2010 18:51:34 +0200
parents ec7cea92fe8a
children 032090a13fe8
files psgxs.js
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/psgxs.js
+++ b/psgxs.js
@@ -522,6 +522,16 @@ function onIq(stanza) {
 					subID = storage.subscribe(nodeID, jid, 'pending', conf);
 					if (typeof subID == 'number')
 						return makeError(response, subID);
+
+					var affiliates = storage.getAffiliationsFromNodeID(nodeID);
+					var form = forms.build('form', 'subscribe_authorization', {allow: false, node: nodeID, subscriber_jid: jid}, true); //168
+
+					for (var i in affiliates) {
+						if (affiliates[i] == 'super-owner' || affiliates[i] == 'owner') {
+							var message = xmpp.message({to: i}).cnode(form);
+							conn.send(message);
+						}
+					}
 				} else if (configuration['pubsub#access_model'] == 'whitelist') {
 					var affil = storage.getAffiliation(jid, nodeID);
 					if (affil != 'super-owner' && affil != 'owner' && affil != 'publisher' && affil != 'member')
@@ -538,17 +548,6 @@ function onIq(stanza) {
 				if (conf)
 					response.cnode(options);
 
-				if (config.enabled('get-pending')) {
-					var affiliates = storage.getAffiliationsFromNodeID(nodeID);
-					var form = forms.build('form', 'subscribe_authorization', {allow: false, node: nodeID, subscriber_jid: jid}, true); //168
-					for (var i in affiliates) {
-						if (affiliates[i] == 'super-owner' || affiliates[i] == 'owner') {
-							var message = xmpp.message({to: i}).cnode(form);
-							conn.send(message);
-						}
-					}
-				}
-
 				if (config.enabled('last-published')) {
 					var last = storage.getLastItem(nodeID);
 					if (typeof last != 'number') {