1
0
Fork 0
mirror of https://github.com/processone/ejabberd synced 2025-10-03 01:39:35 +02:00

Add support to replace keywords in modules options

This commit is contained in:
Badlop 2025-02-10 16:34:38 +01:00
parent 6e68c2ec02
commit 998690f58c

View file

@ -551,10 +551,10 @@ validator(Host, Module, Opts) ->
lists:mapfoldl(
fun({Opt, Def}, {DAcc1, VAcc1}) ->
{[], {DAcc1#{Opt => Def},
VAcc1#{Opt => get_opt_type(Module, M, Opt)}}};
VAcc1#{Opt => get_opt_type(Host, Module, M, Opt)}}};
(Opt, {DAcc1, VAcc1}) ->
{[Opt], {DAcc1,
VAcc1#{Opt => get_opt_type(Module, M, Opt)}}}
VAcc1#{Opt => get_opt_type(Host, Module, M, Opt)}}}
end, {DAcc, VAcc}, DefOpts)
end, {#{}, #{}}, get_defaults(Host, Module, Opts)),
econf:and_then(
@ -604,11 +604,16 @@ get_defaults(Host, Module, Opts) ->
false
end, DefaultOpts)].
-spec get_opt_type(module(), module(), atom()) -> econf:validator().
get_opt_type(Mod, SubMod, Opt) ->
try SubMod:mod_opt_type(Opt)
-spec get_opt_type(binary(), module(), module(), atom()) -> econf:validator().
get_opt_type(Host, Mod, SubMod, Opt) ->
Type = try SubMod:mod_opt_type(Opt)
catch _:_ -> Mod:mod_opt_type(Opt)
end.
end,
econf:and_then(
fun(B) ->
ejabberd_config:replace_keywords(Host, B)
end,
Type).
-spec sort_modules(binary(), [{module(), opts()}]) -> {ok, [{module(), opts(), integer()}]}.
sort_modules(Host, ModOpts) ->