diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-05-30 02:06:04 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-05-30 02:06:04 +0500 |
commit | 66e22f3c576fcb4666a0eb8156015cdd2bb79e2c (patch) | |
tree | 21153ddf0f45c06f76d320a6ffbd46a4b19e9e34 /core/stanza_router.lua | |
parent | 887dc6887baa16d13ff5d06af44c74c2439ee3b6 (diff) | |
download | prosody-66e22f3c576fcb4666a0eb8156015cdd2bb79e2c.tar.gz prosody-66e22f3c576fcb4666a0eb8156015cdd2bb79e2c.zip |
stanza_router: Fire per-host stanza events
Diffstat (limited to 'core/stanza_router.lua')
-rw-r--r-- | core/stanza_router.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua index b739c99e..35593b35 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -124,7 +124,38 @@ function core_post_stanza(origin, stanza) local node, host, resource = jid_split(to); local to_bare = node and (node.."@"..host) or host; -- bare JID + local to_type; + if node then + if resource then + to_type = '/full'; + else + to_type = '/bare'; + end + else + if host then + to_type = '/host'; + else + to_type = '/bare'; + end + end + local event_data = {origin=origin, stanza=stanza}; + if origin.full_jid then -- c2s connection + if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data); then return; end -- do preprocessing + end + local h = hosts[to_bare] or hosts[host or origin.host]; + if h then + if h.type == "component" then + component_handle_stanza(origin, stanza); + return; + else + if h.events.fire_event(stanza.name..to_type, event_data); then return; end -- do processing + end + else -- non-local recipient + core_route_stanza(origin, stanza); + return; + end + if host and fire_event(host.."/"..stanza.name, event_data) then -- event handled elseif stanza.name == "presence" and origin.host and fire_event(origin.host.."/"..stanza.name, event_data) then |