aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-05-16 03:58:05 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-05-16 03:58:05 +0500
commit770011c63a48cc4f06250d3eed979a3d39b50012 (patch)
treea6b40f55d744060e1852b014ed4fcd98fea1d937
parentb199ffcb606dda6da46a749c4fc853a56b04cd1b (diff)
downloadprosody-770011c63a48cc4f06250d3eed979a3d39b50012.tar.gz
prosody-770011c63a48cc4f06250d3eed979a3d39b50012.zip
stanza_router: Added global function core_post_stanza
-rw-r--r--core/stanza_router.lua40
1 files changed, 24 insertions, 16 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index eaff7c66..6eb04ae2 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -109,27 +109,35 @@ function core_process_stanza(origin, stanza)
return; -- FIXME what should we do here? does this work with subdomains?
end
end
- local event_data = {origin=origin, stanza=stanza};
- if fire_event(tostring(host or origin.host).."/"..stanza.name, event_data) then
- -- event handled
- elseif not to then
- modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
- elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server
- modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
- elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server
- component_handle_stanza(origin, stanza);
- elseif hosts[host] and hosts[host].type == "component" then -- directed at a component
- component_handle_stanza(origin, stanza);
- elseif hosts[host] and hosts[host].type == "local" and stanza.name == "iq" and not resource then -- directed at bare JID
- modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
- else
- core_route_stanza(origin, stanza);
- end
+ core_post_stanza(origin, stanza);
else
modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
end
end
+function core_post_stanza(origin, stanza)
+ local to = stanza.attr.to;
+ local node, host, resource = jid_split(to);
+ local to_bare = node and (node.."@"..host) or host; -- bare JID
+
+ local event_data = {origin=origin, stanza=stanza};
+ if fire_event(tostring(host or origin.host).."/"..stanza.name, event_data) then
+ -- event handled
+ elseif not to then
+ modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
+ elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server
+ modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
+ elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server
+ component_handle_stanza(origin, stanza);
+ elseif hosts[host] and hosts[host].type == "component" then -- directed at a component
+ component_handle_stanza(origin, stanza);
+ elseif hosts[host] and hosts[host].type == "local" and stanza.name == "iq" and not resource then -- directed at bare JID
+ modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
+ else
+ core_route_stanza(origin, stanza);
+ end
+end
+
function core_route_stanza(origin, stanza)
-- Hooks
--- ...later