Mercurial > psgxs
comparison 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 |
comparison
equal
deleted
inserted
replaced
23:5fc4ee90c1bc | 24:b80ab94da447 |
---|---|
1 var config = require('../configuration'); | |
2 var storage = require('../storage'); | |
3 var forms = require('../forms'); | |
4 var errors = require('../errors'); | |
5 var makeError = errors.makeError; | |
6 var toBareJID = require('../util').toBareJID; | |
7 var NS = require('../namespaces'); | |
8 | |
9 // XEP-0050: Ad-Hoc Commands | |
10 exports.configureSub = { | |
11 type: 'set', | |
12 child: 'command', | |
13 ns: NS.COMMANDS, | |
14 func: function(response, stanza, request, to) { | |
15 var action = request.getAttribute('action'); | |
16 if (action != 'execute') | |
17 return makeError(response, errors.bad_request.n); | |
18 | |
19 var node = request.getAttribute('node'); | |
20 if (node == 'ping') { | |
21 var cmd = xmpp.stanza('command', {xmlns: NS.COMMANDS, | |
22 // sessionid: 'list:20020923T213616Z-700', | |
23 node: node, | |
24 'status': 'completed'}) | |
25 .c('note', {type: 'info'}).t('pong'); | |
26 response.cnode(cmd); | |
27 } else if (node == 'reload') { | |
28 storage.load(); | |
29 response.c('command', {xmlns: NS.COMMANDS, | |
30 node: node, | |
31 'status': 'completed'}) | |
32 .c('note', {type: 'info'}).t('The server has correctly reloaded.'); | |
33 } else | |
34 return makeError(response, errors.bad_request.n); | |
35 | |
36 return response; | |
37 } | |
38 } |