stanza_router: Improved message routing order

Sat, 16 May 2009 02:19:16 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sat, 16 May 2009 02:19:16 +0500
changeset 1169
fdc68aec1d49
parent 1168
dd523bfc9ea9
child 1170
4845372a2c03

stanza_router: Improved message routing order

core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/stanza_router.lua	Sat May 16 02:07:27 2009 +0500
+++ b/core/stanza_router.lua	Sat May 16 02:19:16 2009 +0500
@@ -160,7 +160,9 @@
 		local user = host_session.sessions[node];
 		if user then
 			local res = user.sessions[resource];
-			if not res then
+			if res then -- resource is online...
+				res.send(stanza); -- Yay \o/
+			else
 				-- if we get here, resource was not specified or was unavailable
 				if stanza.name == "presence" then
 					if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then
@@ -211,10 +213,6 @@
 				elseif stanza.attr.type == "get" or stanza.attr.type == "set" then
 					origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
 				end
-			else
-				-- User + resource is online...
-				stanza.attr.to = res.full_jid; -- reset at the end of function
-				res.send(stanza); -- Yay \o/
 			end
 		else
 			-- user not online

mercurial