diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-02-16 13:29:07 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-02-16 13:29:07 +0000 |
commit | 1bb0fa47bc6e6a8f95003078f34f5e64f64a58cf (patch) | |
tree | 30259478fe6de612b19ef6134bcf8bfc84e1e96c | |
parent | 83e4560a6c6485520d2141f0e13abec420898840 (diff) | |
download | prosody-1bb0fa47bc6e6a8f95003078f34f5e64f64a58cf.tar.gz prosody-1bb0fa47bc6e6a8f95003078f34f5e64f64a58cf.zip |
moduleapi: Allow soft dependencies via module:depends(mod, true)
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | core/moduleapi.lua | 8 |
2 files changed, 7 insertions, 2 deletions
@@ -62,6 +62,7 @@ TRUNK - Method for retrieving integer settings from config - It is now easy for modules to expose a Prosody shell command, by adding a shell-command item - Modules can now implement a module.ready method which will be called after server initialization +- module:depends() now accepts a second parameter 'soft' to enable soft dependencies ### Configuration diff --git a/core/moduleapi.lua b/core/moduleapi.lua index b93536b5..50524b32 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -136,10 +136,14 @@ function api:require(lib) return f(); end -function api:depends(name) +function api:depends(name, soft) local modulemanager = require"prosody.core.modulemanager"; if self:get_option_inherited_set("modules_disabled", {}):contains(name) then - error("Dependency on disabled module mod_"..name); + if not soft then + error("Dependency on disabled module mod_"..name); + end + self:log("debug", "Not loading disabled soft dependency mod_%s", name); + return nil, "disabled"; end if not self.dependencies then self.dependencies = {}; |