Mercurial > psgxs
comparison modules/mod_disco.js @ 42:07ca0263a53f
Add an option to hide non-accessible nodes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 26 Feb 2011 17:39:49 +0100 |
parents | bc717575e66a |
children | 023f767662d3 |
comparison
equal
deleted
inserted
replaced
41:bc717575e66a | 42:07ca0263a53f |
---|---|
52 // SECTION 5.2: Discover Nodes | 52 // SECTION 5.2: Discover Nodes |
53 exports.disco_items = { | 53 exports.disco_items = { |
54 type: 'get', | 54 type: 'get', |
55 child: 'query', | 55 child: 'query', |
56 ns: NS.DISCO_ITEMS, | 56 ns: NS.DISCO_ITEMS, |
57 func: function(response, stanza, request) { | 57 func: function(response, stanza, request, to) { |
58 var children; | 58 var children; |
59 var nodeID = request.getAttribute('node'); | 59 var nodeID = request.getAttribute('node'); |
60 if (nodeID && nodeID != '') { | 60 if (nodeID && nodeID != '') { |
61 if (nodeID == NS.COMMANDS) { | 61 if (nodeID == NS.COMMANDS) { |
62 // XEP-0050: Ad-Hoc Commands | 62 // XEP-0050: Ad-Hoc Commands |
82 children = storage.getChildren(); | 82 children = storage.getChildren(); |
83 if (typeof children == 'number') | 83 if (typeof children == 'number') |
84 return makeError(response, children); | 84 return makeError(response, children); |
85 } | 85 } |
86 | 86 |
87 for (var i in children) { | 87 for (var nodeID in children) { |
88 var attr = {jid: config.jid}; | 88 var attr = {jid: config.jid}; |
89 if (children[i] == 'node') { | 89 if (children[nodeID] == 'node') { |
90 if (config.enabled('meta-data')) { | 90 if (config.enabled('meta-data')) { |
91 var metadata = storage.getMetadata(i); | 91 var metadata = storage.getMetadata(nodeID); |
92 if (metadata['pubsub#title']) | 92 if (metadata['pubsub#title']) |
93 attr.name = metadata['pubsub#title']; | 93 attr.name = metadata['pubsub#title']; |
94 | |
95 if (config.hideNonAccessibleNodes) { | |
96 var configuration = storage.getConfiguration(nodeID); | |
97 if (configuration['pubsub#access_model'] == 'whitelist') { | |
98 var affils = storage.getAffiliationsFromNodeID(nodeID); | |
99 var affil = affils[toBareJID(to)]; | |
100 if (!affil || affil == 'outcast') | |
101 continue; | |
102 } | |
103 } | |
94 } | 104 } |
95 attr.node = i; | 105 attr.node = nodeID; |
96 | 106 |
97 // SECTION 5.5: Discover Items for a Node | 107 // SECTION 5.5: Discover Items for a Node |
98 } else | 108 } else |
99 attr.name = i; | 109 attr.name = nodeID; |
100 | 110 |
101 response.c('item', attr).up(); | 111 response.c('item', attr).up(); |
102 } | 112 } |
103 | 113 |
104 return response; | 114 return response; |