Mercurial > prosody-hg
changeset 13910:622790951285
moduleapi: :hook(): don't silently fall back to global events when host unknown
This code will throw an error instead, but it's a situation that shouldn't
happen (especially now :context() rejects unknown hosts).
Related to #605
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 27 Jun 2025 11:12:50 +0100 |
| parents | e6c6f58dfda1 |
| children | 79ae4821c05e |
| files | core/moduleapi.lua |
| diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/core/moduleapi.lua Fri Jun 27 11:11:08 2025 +0100 +++ b/core/moduleapi.lua Fri Jun 27 11:12:50 2025 +0100 @@ -93,7 +93,14 @@ end function api:hook(event, handler, priority) - return self:hook_object_event((hosts[self.host] or prosody).events, event, handler, priority); + local events; + local host = self.host; + if host == "*" then + events = prosody.events; + else + events = hosts[host].events; + end + return self:hook_object_event(events, event, handler, priority); end function api:hook_global(event, handler, priority)
