Mercurial > prosody-hg
changeset 13922:52cf3ec248a9
mod_c2s: Avoid calling module:context() with unknown hosts
Related to e6c6f58dfda1, a0faff6ba853 and #605
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 05 Aug 2025 13:11:28 +0100 |
| parents | 33755e085ca5 |
| children | 7fdf7645b0da |
| files | plugins/mod_c2s.lua |
| diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_c2s.lua Sun Aug 03 15:21:56 2025 +0200 +++ b/plugins/mod_c2s.lua Tue Aug 05 13:11:28 2025 +0100 @@ -210,7 +210,11 @@ local function session_close(session, reason) local log = session.log or log; local close_event_payload = { session = session, reason = reason }; - module:context(session.host):fire_event("pre-session-close", close_event_payload); + + -- Fire event on host if we know it, otherwise fire globally + local context = hosts[session.host] and module:context(session.host) or module:context("*"); + context:fire_event("pre-session-close", close_event_payload); + reason = close_event_payload.reason; if session.conn then if session.notopen then
