25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-31 15:21:38 +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()}]. -spec node_options(host(), binary()) -> [{atom(), any()}].
node_options(Host, Type) -> node_options(Host, Type) ->
DefaultOpts = node_plugin_options(Host, Type),
ConfigOpts = config(Host, default_node_config), ConfigOpts = config(Host, default_node_config),
case lists:member(Type, config(Host, plugins)) of PluginOpts = node_plugin_options(Host, Type),
true -> merge_config([ConfigOpts, PluginOpts]).
merge_config([ConfigOpts, DefaultOpts]);
false -> ConfigOpts
end.
-spec node_plugin_options(host(), binary()) -> [{atom(), any()}]. -spec node_plugin_options(host(), binary()) -> [{atom(), any()}].
node_plugin_options(Host, Type) -> node_plugin_options(Host, Type) ->
Module = plugin(Host, Type), Module = plugin(Host, Type),
case catch Module:options() of case {lists:member(Type, config(Host, plugins)), catch Module:options()} of
{'EXIT', {undef, _}} -> {true, Opts} when is_list(Opts) ->
Opts;
{_, _} ->
DefaultModule = plugin(Host, ?STDNODE), DefaultModule = plugin(Host, ?STDNODE),
DefaultModule:options(); DefaultModule:options()
Result ->
Result
end. end.
-spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()]. -spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].