mod_lastactivity, mod_legacyauth, mod_presence, mod_saslauth, mod_tls: Use the newer...
authorKim Alvefur <zash@zash.se>
Fri, 4 Jul 2014 20:52:34 +0000 (22:52 +0200)
committerKim Alvefur <zash@zash.se>
Fri, 4 Jul 2014 20:52:34 +0000 (22:52 +0200)
plugins/adhoc/adhoc.lib.lua
plugins/mod_lastactivity.lua
plugins/mod_legacyauth.lua
plugins/mod_presence.lua
plugins/mod_saslauth.lua
plugins/mod_tls.lua

index b544ddc8e4ac8ecee986adf2a9a2b94b1748daf0..5c90c91ba8931360cd87d2921504091b292d57eb 100644 (file)
@@ -25,12 +25,13 @@ function _M.new(name, node, handler, permission)
 end
 
 function _M.handle_cmd(command, origin, stanza)
-       local sessionid = stanza.tags[1].attr.sessionid or uuid.generate();
+       local cmdtag = stanza.tags[1]
+       local sessionid = cmdtag.attr.sessionid or uuid.generate();
        local dataIn = {};
        dataIn.to = stanza.attr.to;
        dataIn.from = stanza.attr.from;
-       dataIn.action = stanza.tags[1].attr.action or "execute";
-       dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data");
+       dataIn.action = cmdtag.attr.action or "execute";
+       dataIn.form = cmdtag:get_child("x", "jabber:x:data");
 
        local data, state = command:handler(dataIn, states[sessionid]);
        states[sessionid] = state;
index fabf07b478714df6c09a2132ec649ae2625611e3..2dd61699999dcf5a56fb44dd62a5f0b4514ffe22 100644 (file)
@@ -19,8 +19,7 @@ module:hook("pre-presence/bare", function(event)
        local stanza = event.stanza;
        if not(stanza.attr.to) and stanza.attr.type == "unavailable" then
                local t = os.time();
-               local s = stanza:child_with_name("status");
-               s = s and #s.tags == 0 and s[1] or "";
+               local s = stanza:get_child_text("status");
                map[event.origin.username] = {s = s, t = t};
        end
 end, 10);
index cb5ce0d3c4e6a3676ffa975dcbe70a740bed4309..54cbec24c2c20a6fed1ef7b3147a446112ca33d3 100644 (file)
@@ -44,9 +44,10 @@ module:hook("stanza/iq/jabber:iq:auth:query", function(event)
                return true;
        end
 
-       local username = stanza.tags[1]:child_with_name("username");
-       local password = stanza.tags[1]:child_with_name("password");
-       local resource = stanza.tags[1]:child_with_name("resource");
+       local query = stanza.tags[1];
+       local username = query:get_child("username");
+       local password = query:get_child("password");
+       local resource = query:get_child("resource");
        if not (username and password and resource) then
                local reply = st.reply(stanza);
                session.send(reply:query("jabber:iq:auth")
index 2577573c4d4b26f2b985016b14b79ea1785fc436..9e8f37dbe94a8dfe3aab528372c025203a2545dd 100644 (file)
@@ -55,14 +55,14 @@ local ignore_presence_priority = module:get_option("ignore_presence_priority");
 
 function handle_normal_presence(origin, stanza)
        if ignore_presence_priority then
-               local priority = stanza:child_with_name("priority");
+               local priority = stanza:get_child("priority");
                if priority and priority[1] ~= "0" then
                        for i=#priority.tags,1,-1 do priority.tags[i] = nil; end
                        for i=#priority,1,-1 do priority[i] = nil; end
                        priority[1] = "0";
                end
        end
-       local priority = stanza:child_with_name("priority");
+       local priority = stanza:get_child("priority");
        if priority and #priority > 0 then
                priority = t_concat(priority);
                if s_find(priority, "^[+-]?[0-9]+$") then
index df60aefa36d09a6278555a9bb65ba9d596da1651..a07c5fd2a487d27742ca73c3f6ba711d23ffa806 100644 (file)
@@ -284,7 +284,7 @@ module:hook("iq/self/urn:ietf:params:xml:ns:xmpp-bind:bind", function(event)
        local resource;
        if stanza.attr.type == "set" then
                local bind = stanza.tags[1];
-               resource = bind:child_with_name("resource");
+               resource = bind:get_child("resource");
                resource = resource and #resource.tags == 0 and resource[1] or nil;
        end
        local success, err_type, err, err_msg = sm_bind_resource(origin, resource);
index 5ae083d49fa8bf6b39118c96ba3f18fd14b2e77f..351aaffc9708ead631446118096334067e0a2f4d 100644 (file)
@@ -108,7 +108,7 @@ end);
 -- For s2sout connections, start TLS if we can
 module:hook_stanza("http://etherx.jabber.org/streams", "features", function (session, stanza)
        module:log("debug", "Received features element");
-       if can_do_tls(session) and stanza:child_with_ns(xmlns_starttls) then
+       if can_do_tls(session) and stanza:get_child("starttls", xmlns_starttls) then
                module:log("debug", "%s is offering TLS, taking up the offer...", session.to_host);
                session.sends2s("<starttls xmlns='"..xmlns_starttls.."'/>");
                return true;