xmpp{client,server}_listener: Put stanzas/in filtering code in the correct place to make it actually work :)

Thu, 08 Jul 2010 14:28:42 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 08 Jul 2010 14:28:42 +0100
changeset 3332
c941d1191709
parent 3331
57a9cf5f4259
child 3333
e6bb6bc4cfbe

xmpp{client,server}_listener: Put stanzas/in filtering code in the correct place to make it actually work :)

net/xmppclient_listener.lua file | annotate | diff | comparison | revisions
net/xmppserver_listener.lua file | annotate | diff | comparison | revisions
--- a/net/xmppclient_listener.lua	Thu Jul 08 14:08:27 2010 +0100
+++ b/net/xmppclient_listener.lua	Thu Jul 08 14:28:42 2010 +0100
@@ -63,8 +63,11 @@
 end
 
 local function handleerr(err) log("error", "Traceback[c2s]: %s: %s", tostring(err), debug.traceback()); end
-function stream_callbacks.handlestanza(a, b)
-	xpcall(function () core_process_stanza(a, b) end, handleerr);
+function stream_callbacks.handlestanza(session, stanza)
+	stanza = session.filter("stanzas/in", stanza);
+	if stanza then
+		xpcall(function () core_process_stanza(session, stanza) end, handleerr);
+	end
 end
 
 local sessions = {};
@@ -151,10 +154,7 @@
 	
 	local handlestanza = stream_callbacks.handlestanza;
 	function session.dispatch_stanza(session, stanza)
-		stanza = filter("stanzas/in", stanza);
-		if stanza then
-			return handlestanza(session, stanza);
-		end
+		return handlestanza(session, stanza);
 	end
 end
 
--- a/net/xmppserver_listener.lua	Thu Jul 08 14:08:27 2010 +0100
+++ b/net/xmppserver_listener.lua	Thu Jul 08 14:28:42 2010 +0100
@@ -49,11 +49,14 @@
 end
 
 local function handleerr(err) log("error", "Traceback[s2s]: %s: %s", tostring(err), debug.traceback()); end
-function stream_callbacks.handlestanza(a, b)
-	if b.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
-		b.attr.xmlns = nil;
+function stream_callbacks.handlestanza(session, stanza)
+	if stanza.attr.xmlns == "jabber:client" then --COMPAT: Prosody pre-0.6.2 may send jabber:client
+		stanza.attr.xmlns = nil;
 	end
-	xpcall(function () core_process_stanza(a, b) end, handleerr);
+	stanza = session.filter("stanzas/in", stanza);
+	if stanza then
+		xpcall(function () core_process_stanza(a, b) end, handleerr);
+	end
 end
 
 local connlisteners_register = require "net.connlisteners".register;
@@ -140,10 +143,7 @@
 	session.close = session_close;
 	local handlestanza = stream_callbacks.handlestanza;
 	function session.dispatch_stanza(session, stanza)
-		stanza = filters("stanzas/in", stanza);
-		if stanza then
-			return handlestanza(session, stanza);
-		end
+		return handlestanza(session, stanza);
 	end
 end
 

mercurial