122 function core_post_stanza(origin, stanza, preevents) |
122 function core_post_stanza(origin, stanza, preevents) |
123 local to = stanza.attr.to; |
123 local to = stanza.attr.to; |
124 local node, host, resource = jid_split(to); |
124 local node, host, resource = jid_split(to); |
125 local to_bare = node and (node.."@"..host) or host; -- bare JID |
125 local to_bare = node and (node.."@"..host) or host; -- bare JID |
126 |
126 |
127 local to_type; |
127 local to_type, to_self; |
128 if node then |
128 if node then |
129 if resource then |
129 if resource then |
130 to_type = '/full'; |
130 to_type = '/full'; |
131 else |
131 else |
132 to_type = '/bare'; |
132 to_type = '/bare'; |
133 if node == origin.username and host == origin.host then |
133 if node == origin.username and host == origin.host then |
134 stanza.attr.to = nil; |
134 stanza.attr.to = nil; |
|
135 to_self = true; |
135 end |
136 end |
136 end |
137 end |
137 else |
138 else |
138 if host then |
139 if host then |
139 to_type = '/host'; |
140 to_type = '/host'; |
147 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing |
148 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing |
148 end |
149 end |
149 local h = hosts[to_bare] or hosts[host or origin.host]; |
150 local h = hosts[to_bare] or hosts[host or origin.host]; |
150 if h then |
151 if h then |
151 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing |
152 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing |
|
153 if to_self and h.events.fire_event(stanza.name..'/self', event_data) then return; end -- do processing |
152 |
154 |
153 if h.type == "component" then |
155 if h.type == "component" then |
154 component_handle_stanza(origin, stanza); |
156 component_handle_stanza(origin, stanza); |
155 return; |
157 return; |
156 end |
158 end |