Software /
code /
prosody
Diff
core/modulemanager.lua @ 191:e64c8a44060f
Fix s2s once and for all
- Moved dialback to the new mod_dialback (mostly).
- Modules can now supply a list of origins to handle to add_handler
- Modules can now handle and process any stanza, overriding the core
- Modules handle non-jabber:client/jabber:server xmlns'd stanzas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 01 Nov 2008 21:07:14 +0000 |
parent | 188:0d9f03009b8a |
child | 196:ebe23269b377 |
line wrap: on
line diff
--- a/core/modulemanager.lua Sat Nov 01 18:28:46 2008 +0000 +++ b/core/modulemanager.lua Sat Nov 01 21:07:14 2008 +0000 @@ -31,19 +31,29 @@ end end -function modulehelpers.add_handler(origin_type, tag, xmlns, handler) - if not (origin_type and tag and xmlns and handler) then return false; end +local function _add_handler(module, origin_type, tag, xmlns, handler) handlers[origin_type] = handlers[origin_type] or {}; if not handlers[origin_type][tag] then handlers[origin_type][tag] = handlers[origin_type][tag] or {}; handlers[origin_type][tag][xmlns]= handler; - handler_info[handler] = getfenv(2).module; - log("debug", "mod_%s now handles tag '%s'", getfenv(2).module.name, tag); + handler_info[handler] = module; + log("debug", "mod_%s now handles tag '%s'", module.name, tag); elseif handler_info[handlers[origin_type][tag]] then - log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", getfenv(2).module.name, tag, handler_info[handlers[origin_type][tag]].module.name); + log("warning", "mod_%s wants to handle tag '%s' but mod_%s already handles that", module.name, tag, handler_info[handlers[origin_type][tag]].module.name); end end +function modulehelpers.add_handler(origin_type, tag, xmlns, handler) + if not (origin_type and tag and xmlns and handler) then return false; end + if type(origin_type) == "table" then + for _, origin_type in ipairs(origin_type) do + _add_handler(getfenv(2).module, origin_type, tag, xmlns, handler); + end + return; + end + _add_handler(getfenv(2).module, origin_type, tag, xmlns, handler); +end + function loadall() load("saslauth"); load("legacyauth"); @@ -53,6 +63,7 @@ load("vcard"); load("private"); load("version"); + load("dialback"); end function load(name)