Software /
code /
prosody
Comparison
core/stanza_router.lua @ 10645:067ada779ea5
stanza_router: only fire pre-stanza if firing other preevents (e.g. for c2s sessions)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 05 Feb 2020 22:53:59 +0000 |
parent | 10639:08e3063eb1ac |
child | 11629:e6e56e2dd996 |
comparison
equal
deleted
inserted
replaced
10644:6c4ab1b87588 | 10645:067ada779ea5 |
---|---|
172 end | 172 end |
173 end | 173 end |
174 | 174 |
175 local event_data = {origin=origin, stanza=stanza, to_self=to_self}; | 175 local event_data = {origin=origin, stanza=stanza, to_self=to_self}; |
176 | 176 |
177 local result = hosts[origin.host].events.fire_event("pre-stanza", event_data); | |
178 if result ~= nil then | |
179 log("debug", "Stanza rejected by pre-stanza handler: %s", event_data.reason or "unknown reason"); | |
180 return; | |
181 end | |
182 | |
183 if preevents then -- c2s connection | 177 if preevents then -- c2s connection |
178 local result = hosts[origin.host].events.fire_event("pre-stanza", event_data); | |
179 if result ~= nil then | |
180 log("debug", "Stanza rejected by pre-stanza handler: %s", event_data.reason or "unknown reason"); | |
181 return; | |
182 end | |
183 | |
184 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing | 184 if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing |
185 end | 185 end |
186 local h = hosts[to_bare] or hosts[host or origin.host]; | 186 local h = hosts[to_bare] or hosts[host or origin.host]; |
187 if h then | 187 if h then |
188 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing | 188 if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing |