Mercurial > psgxs
diff modules/mod_adhoc.js @ 24:b80ab94da447
Add new modules files.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 01 Nov 2010 00:02:27 +0100 |
parents | |
children | b2faacfefb90 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/modules/mod_adhoc.js @@ -0,0 +1,38 @@ +var config = require('../configuration'); +var storage = require('../storage'); +var forms = require('../forms'); +var errors = require('../errors'); +var makeError = errors.makeError; +var toBareJID = require('../util').toBareJID; +var NS = require('../namespaces'); + +// XEP-0050: Ad-Hoc Commands +exports.configureSub = { + type: 'set', + child: 'command', + ns: NS.COMMANDS, + func: function(response, stanza, request, to) { + var action = request.getAttribute('action'); + if (action != 'execute') + return makeError(response, errors.bad_request.n); + + var node = request.getAttribute('node'); + if (node == 'ping') { + var cmd = xmpp.stanza('command', {xmlns: NS.COMMANDS, + // sessionid: 'list:20020923T213616Z-700', + node: node, + 'status': 'completed'}) + .c('note', {type: 'info'}).t('pong'); + response.cnode(cmd); + } else if (node == 'reload') { + storage.load(); + response.c('command', {xmlns: NS.COMMANDS, + node: node, + 'status': 'completed'}) + .c('note', {type: 'info'}).t('The server has correctly reloaded.'); + } else + return makeError(response, errors.bad_request.n); + + return response; + } +}