mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Strip duplicates from module's options
This commit is contained in:
parent
bc808ffcde
commit
c3eeb8624b
@ -555,7 +555,8 @@ validate_opts(Host, Module, Opts0) ->
|
||||
undef ->
|
||||
Opts;
|
||||
Validators ->
|
||||
validate_opts(Host, Module, Opts, Required, Validators)
|
||||
Opts1 = validate_opts(Host, Module, Opts, Required, Validators),
|
||||
remove_duplicated_opts(Opts1)
|
||||
end}
|
||||
catch _:{missing_required_option, Opt} ->
|
||||
ErrTxt = io_lib:format("Module '~s' is missing required option '~s'",
|
||||
@ -680,6 +681,16 @@ merge_opts(Opts, DefaultOpts) ->
|
||||
end
|
||||
end, Result, Opts).
|
||||
|
||||
remove_duplicated_opts([{Opt, Val}, {Opt, _Default}|Opts]) ->
|
||||
[{Opt, Val}|remove_duplicated_opts(Opts)];
|
||||
remove_duplicated_opts([{Opt, [{SubOpt, _}|_] = SubOpts}|Opts])
|
||||
when is_atom(SubOpt) ->
|
||||
[{Opt, remove_duplicated_opts(SubOpts)}|remove_duplicated_opts(Opts)];
|
||||
remove_duplicated_opts([OptVal|Opts]) ->
|
||||
[OptVal|remove_duplicated_opts(Opts)];
|
||||
remove_duplicated_opts([]) ->
|
||||
[].
|
||||
|
||||
-spec get_submodules(binary(), module(), opts()) -> [module()].
|
||||
get_submodules(Host, Module, Opts) ->
|
||||
try Module:mod_options(Host) of
|
||||
|
Loading…
Reference in New Issue
Block a user