From 1bb0fa47bc6e6a8f95003078f34f5e64f64a58cf Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 16 Feb 2025 13:29:07 +0000 Subject: moduleapi: Allow soft dependencies via module:depends(mod, true) --- core/moduleapi.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/moduleapi.lua') 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 = {}; -- cgit v1.2.3