mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Add support to replace keywords in modules options
This commit is contained in:
parent
6e68c2ec02
commit
998690f58c
1 changed files with 11 additions and 6 deletions
|
@ -551,10 +551,10 @@ validator(Host, Module, Opts) ->
|
||||||
lists:mapfoldl(
|
lists:mapfoldl(
|
||||||
fun({Opt, Def}, {DAcc1, VAcc1}) ->
|
fun({Opt, Def}, {DAcc1, VAcc1}) ->
|
||||||
{[], {DAcc1#{Opt => Def},
|
{[], {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], {DAcc1,
|
{[Opt], {DAcc1,
|
||||||
VAcc1#{Opt => get_opt_type(Module, M, Opt)}}}
|
VAcc1#{Opt => get_opt_type(Host, Module, M, Opt)}}}
|
||||||
end, {DAcc, VAcc}, DefOpts)
|
end, {DAcc, VAcc}, DefOpts)
|
||||||
end, {#{}, #{}}, get_defaults(Host, Module, Opts)),
|
end, {#{}, #{}}, get_defaults(Host, Module, Opts)),
|
||||||
econf:and_then(
|
econf:and_then(
|
||||||
|
@ -604,11 +604,16 @@ get_defaults(Host, Module, Opts) ->
|
||||||
false
|
false
|
||||||
end, DefaultOpts)].
|
end, DefaultOpts)].
|
||||||
|
|
||||||
-spec get_opt_type(module(), module(), atom()) -> econf:validator().
|
-spec get_opt_type(binary(), module(), module(), atom()) -> econf:validator().
|
||||||
get_opt_type(Mod, SubMod, Opt) ->
|
get_opt_type(Host, Mod, SubMod, Opt) ->
|
||||||
try SubMod:mod_opt_type(Opt)
|
Type = try SubMod:mod_opt_type(Opt)
|
||||||
catch _:_ -> Mod: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()}]}.
|
-spec sort_modules(binary(), [{module(), opts()}]) -> {ok, [{module(), opts(), integer()}]}.
|
||||||
sort_modules(Host, ModOpts) ->
|
sort_modules(Host, ModOpts) ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue