# HG changeset patch # User Emmanuel Gil Peyrot # Date 1298738389 -3600 # Node ID 07ca0263a53fb542e2ab7329f18a3dbd941f89aa # Parent bc717575e66aa5bb0a268842c18af76186390f96 Add an option to hide non-accessible nodes. diff --git a/configuration.js b/configuration.js --- a/configuration.js +++ b/configuration.js @@ -28,6 +28,7 @@ config.allowCreateNode = [/@example\.com config.backend = 'directory'; // Put backends in “backends” directory. config.access = 'open'; // values include open, whitelist (by members) and authorize (owners of the node receive notification). presence and roster aren’t implemented yet. config.pluginsDir = 'modules'; +config.hideNonAccessibleNodes = true; config.activated = [ 'auto-create', diff --git a/modules/mod_disco.js b/modules/mod_disco.js --- a/modules/mod_disco.js +++ b/modules/mod_disco.js @@ -54,7 +54,7 @@ exports.disco_items = { type: 'get', child: 'query', ns: NS.DISCO_ITEMS, - func: function(response, stanza, request) { + func: function(response, stanza, request, to) { var children; var nodeID = request.getAttribute('node'); if (nodeID && nodeID != '') { @@ -84,19 +84,29 @@ exports.disco_items = { return makeError(response, children); } - for (var i in children) { + for (var nodeID in children) { var attr = {jid: config.jid}; - if (children[i] == 'node') { + if (children[nodeID] == 'node') { if (config.enabled('meta-data')) { - var metadata = storage.getMetadata(i); + var metadata = storage.getMetadata(nodeID); if (metadata['pubsub#title']) attr.name = metadata['pubsub#title']; + + if (config.hideNonAccessibleNodes) { + var configuration = storage.getConfiguration(nodeID); + if (configuration['pubsub#access_model'] == 'whitelist') { + var affils = storage.getAffiliationsFromNodeID(nodeID); + var affil = affils[toBareJID(to)]; + if (!affil || affil == 'outcast') + continue; + } + } } - attr.node = i; + attr.node = nodeID; // SECTION 5.5: Discover Items for a Node } else - attr.name = i; + attr.name = nodeID; response.c('item', attr).up(); }