2 -- |
2 -- |
3 -- This file is MIT/X11 licensed. Please see the |
3 -- This file is MIT/X11 licensed. Please see the |
4 -- COPYING file in the source package for more information. |
4 -- COPYING file in the source package for more information. |
5 -- |
5 -- |
6 |
6 |
7 local st, uuid = require "util.stanza", require "util.uuid"; |
7 local st, new_id = require "util.stanza", require "util.id".short; |
8 |
8 |
9 local xmlns_cmd = "http://jabber.org/protocol/commands"; |
9 local xmlns_cmd = "http://jabber.org/protocol/commands"; |
10 |
10 |
11 local states = {} |
11 local states = {} |
12 |
12 |
23 function _M.new(name, node, handler, permission) |
23 function _M.new(name, node, handler, permission) |
24 return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = (permission or "user") }; |
24 return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = (permission or "user") }; |
25 end |
25 end |
26 |
26 |
27 function _M.handle_cmd(command, origin, stanza) |
27 function _M.handle_cmd(command, origin, stanza) |
28 local sessionid = stanza.tags[1].attr.sessionid or uuid.generate(); |
28 local sessionid = stanza.tags[1].attr.sessionid or new_id(); |
29 local dataIn = {}; |
29 local dataIn = {}; |
30 dataIn.to = stanza.attr.to; |
30 dataIn.to = stanza.attr.to; |
31 dataIn.from = stanza.attr.from; |
31 dataIn.from = stanza.attr.from; |
32 dataIn.action = stanza.tags[1].attr.action or "execute"; |
32 dataIn.action = stanza.tags[1].attr.action or "execute"; |
33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); |
33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); |