local array, set = require "util.array", require "util.set";
local autoload_modules = {"presence", "message", "iq"};
-local component_inheritable_modules = {"tls", "dialback"};
+local component_inheritable_modules = {"tls", "dialback", "iq"};
-- We need this to let modules access the real global namespace
local _G = _G;
local host_modules = set.new(host_modules_enabled) - set.new(host_modules_disabled);
local global_modules = set.new(autoload_modules) + set.new(global_modules_enabled) - set.new(global_modules_disabled);
if component then
- global_modules = set.new(component_inheritable_modules) - global_modules;
+ global_modules = set.intersection(set.new(component_inheritable_modules), global_modules);
end
local modules = global_modules + host_modules;
end
end
prosody_events.add_handler("host-activated", load_modules_for_host);
-prosody_events.add_handler("component-activated", load_modules_for_host);
--
function load(host, module_name, config)
if not (host and module_name) then
return nil, "insufficient-parameters";
+ elseif not hosts[host] then
+ return nil, "unknown-host";
end
if not modulemap[host] then
api_instance.environment = pluginenv;
setfenv(mod, pluginenv);
- if not hosts[host] then
- local create_component = _G.require "core.componentmanager".create_component;
- hosts[host] = create_component(host);
- log("debug", "Created new component: %s", host);
- end
hosts[host].modules = modulemap[host];
modulemap[host][module_name] = pluginenv;