# HG changeset patch # User Matthew Wild # Date 1739712547 0 # Node ID 4309c934e8132f79dde9f91d6f0bc30661dd601e # Parent 569fae28a2f3f70cd042c4fb26e68e60925d8810 moduleapi: Allow soft dependencies via module:depends(mod, true) diff -r 569fae28a2f3 -r 4309c934e813 CHANGES --- a/CHANGES Sun Feb 16 13:19:05 2025 +0000 +++ b/CHANGES Sun Feb 16 13:29:07 2025 +0000 @@ -62,6 +62,7 @@ - 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 -r 569fae28a2f3 -r 4309c934e813 core/moduleapi.lua --- a/core/moduleapi.lua Sun Feb 16 13:19:05 2025 +0000 +++ b/core/moduleapi.lua Sun Feb 16 13:29:07 2025 +0000 @@ -136,10 +136,14 @@ 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 = {};