mod_dialback: Use stanza:get_text() instead of directly accessing [1]

Wed, 05 Jan 2011 05:12:54 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Wed, 05 Jan 2011 05:12:54 +0000
changeset 4001
ed90aace9add
parent 4000
279a3f9f540c
child 4002
2b53b4b5d46e

mod_dialback: Use stanza:get_text() instead of directly accessing [1]

plugins/mod_dialback.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_dialback.lua	Wed Jan 05 05:12:22 2011 +0000
+++ b/plugins/mod_dialback.lua	Wed Jan 05 05:12:54 2011 +0000
@@ -33,14 +33,14 @@
 		-- COMPAT: Grr, ejabberd breaks this one too?? it is black and white in XEP-220 example 34
 		--if attr.from ~= origin.to_host then error("invalid-from"); end
 		local type;
-		if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza[1]) then
+		if s2s_verify_dialback(attr.id, attr.from, attr.to, stanza:get_text()) then
 			type = "valid"
 		else
 			type = "invalid"
 			origin.log("warn", "Asked to verify a dialback key that was incorrect. An imposter is claiming to be %s?", attr.to);
 		end
 		origin.log("debug", "verified dialback key... it is %s", type);
-		origin.sends2s(st.stanza("db:verify", { from = attr.to, to = attr.from, id = attr.id, type = type }):text(stanza[1]));
+		origin.sends2s(st.stanza("db:verify", { from = attr.to, to = attr.from, id = attr.id, type = type }):text(stanza:get_text()));
 		return true;
 	end
 end);
@@ -52,7 +52,7 @@
 		-- he wants to be identified through dialback
 		-- We need to check the key with the Authoritative server
 		local attr = stanza.attr;
-		origin.hosts[attr.from] = { dialback_key = stanza[1] };
+		origin.hosts[attr.from] = { dialback_key = stanza:get_text() };
 		
 		if not hosts[attr.to] then
 			-- Not a host that we serve
@@ -72,9 +72,9 @@
 			origin.to_host = attr.to;
 		end
 		
-		origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza[1]);
+		origin.log("debug", "asking %s if key %s belongs to them", attr.from, stanza:get_text());
 		send_s2s(attr.to, attr.from,
-			st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza[1]));
+			st.stanza("db:verify", { from = attr.to, to = attr.from, id = origin.streamid }):text(stanza:get_text()));
 		return true;
 	end
 end);

mercurial