Comparison

plugins/adhoc/adhoc.lib.lua @ 6302:76699a0ae4c4

mod_lastactivity, mod_legacyauth, mod_presence, mod_saslauth, mod_tls: Use the newer stanza:get_child APIs and optimize away some table lookups
author Kim Alvefur <zash@zash.se>
date Fri, 04 Jul 2014 22:52:34 +0200
parent 5758:ebc074918173
child 7951:2b91da49285a
comparison
equal deleted inserted replaced
6301:2fdd71b08126 6302:76699a0ae4c4
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 cmdtag = stanza.tags[1]
29 local sessionid = cmdtag.attr.sessionid or uuid.generate();
29 local dataIn = {}; 30 local dataIn = {};
30 dataIn.to = stanza.attr.to; 31 dataIn.to = stanza.attr.to;
31 dataIn.from = stanza.attr.from; 32 dataIn.from = stanza.attr.from;
32 dataIn.action = stanza.tags[1].attr.action or "execute"; 33 dataIn.action = cmdtag.attr.action or "execute";
33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); 34 dataIn.form = cmdtag:get_child("x", "jabber:x:data");
34 35
35 local data, state = command:handler(dataIn, states[sessionid]); 36 local data, state = command:handler(dataIn, states[sessionid]);
36 states[sessionid] = state; 37 states[sessionid] = state;
37 local cmdtag; 38 local cmdtag;
38 if data.status == "completed" then 39 if data.status == "completed" then