Mercurial > prosody-hg
comparison core/modulemanager.lua @ 14038:1a2691bd50bd 13.0
modulemanager: Allow component modules to specify additional inherited modules
If a component module knows some extra modules which are traditionally loaded
globally that might apply to it, it can declare them:
--% inherit_modules: server_contact_info
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 12 Jan 2026 17:17:51 +0000 |
| parents | dde0ce03049b |
| children | fc29a8c1f873 |
comparison
equal
deleted
inserted
replaced
| 14037:cc916272c30f | 14038:1a2691bd50bd |
|---|---|
| 35 "offline", | 35 "offline", |
| 36 "c2s", | 36 "c2s", |
| 37 "s2s", | 37 "s2s", |
| 38 "s2s_auth_certs", | 38 "s2s_auth_certs", |
| 39 }; | 39 }; |
| 40 local component_inheritable_modules = { | 40 local default_component_inheritable_modules = { |
| 41 "tls", | 41 "tls", |
| 42 "saslauth", | 42 "saslauth", |
| 43 "dialback", | 43 "dialback", |
| 44 "iq", | 44 "iq", |
| 45 "s2s", | 45 "s2s", |
| 126 if host_modules_enabled == global_modules_enabled then host_modules_enabled = nil; end | 126 if host_modules_enabled == global_modules_enabled then host_modules_enabled = nil; end |
| 127 if host_modules_disabled == global_modules_disabled then host_modules_disabled = nil; end | 127 if host_modules_disabled == global_modules_disabled then host_modules_disabled = nil; end |
| 128 | 128 |
| 129 local global_modules = set.new(autoload_modules) + set.new(global_modules_enabled) - set.new(global_modules_disabled); | 129 local global_modules = set.new(autoload_modules) + set.new(global_modules_enabled) - set.new(global_modules_disabled); |
| 130 if component then | 130 if component then |
| 131 global_modules = set.intersection(set.new(component_inheritable_modules), global_modules); | 131 local component_inheritable_modules = set.new(default_component_inheritable_modules); |
| 132 local ok, _, metadata = loader:load_resource(component); | |
| 133 if ok then | |
| 134 local extra_inheritable_modules = metadata.inherit_modules; | |
| 135 if extra_inheritable_modules then | |
| 136 for inherit_module in extra_inheritable_modules:gmatch("[^, ]+") do | |
| 137 component_inheritable_modules:add(inherit_module); | |
| 138 end | |
| 139 end | |
| 140 end | |
| 141 global_modules = set.intersection(component_inheritable_modules, global_modules); | |
| 132 end | 142 end |
| 133 local modules = (global_modules + set.new(host_modules_enabled)) - set.new(host_modules_disabled); | 143 local modules = (global_modules + set.new(host_modules_enabled)) - set.new(host_modules_disabled); |
| 134 | 144 |
| 135 if modules:contains("vcard") and modules:contains("vcard_legacy") then | 145 if modules:contains("vcard") and modules:contains("vcard_legacy") then |
| 136 log("error", "The mod_vcard_legacy plugin replaces mod_vcard but both are enabled. Please update your config."); | 146 log("error", "The mod_vcard_legacy plugin replaces mod_vcard but both are enabled. Please update your config."); |
