25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

mod_pubsub: Fall back to default plugin options

If the plugin handling a node creation request isn't enabled, fall back
to applying the default plugin (currently node_flat) options.
This commit is contained in:
Holger Weiss 2024-09-28 17:58:07 +02:00
parent a9583b43c3
commit 36187e07d0

View File

@ -3366,23 +3366,19 @@ get_option(Options, Var, Def) ->
-spec node_options(host(), binary()) -> [{atom(), any()}].
node_options(Host, Type) ->
DefaultOpts = node_plugin_options(Host, Type),
ConfigOpts = config(Host, default_node_config),
case lists:member(Type, config(Host, plugins)) of
true ->
merge_config([ConfigOpts, DefaultOpts]);
false -> ConfigOpts
end.
PluginOpts = node_plugin_options(Host, Type),
merge_config([ConfigOpts, PluginOpts]).
-spec node_plugin_options(host(), binary()) -> [{atom(), any()}].
node_plugin_options(Host, Type) ->
Module = plugin(Host, Type),
case catch Module:options() of
{'EXIT', {undef, _}} ->
case {lists:member(Type, config(Host, plugins)), catch Module:options()} of
{true, Opts} when is_list(Opts) ->
Opts;
{_, _} ->
DefaultModule = plugin(Host, ?STDNODE),
DefaultModule:options();
Result ->
Result
DefaultModule:options()
end.
-spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].