Software /
code /
prosody
Changeset
13719:4309c934e813 13.0
moduleapi: Allow soft dependencies via module:depends(mod, true)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 16 Feb 2025 13:29:07 +0000 |
parents | 13718:569fae28a2f3 |
children | 13720:c3c4281c1339 |
files | CHANGES core/moduleapi.lua |
diffstat | 2 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 = {};