From 36187e07d0652e5c2f891f48cdf958b872a70f5d Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sat, 28 Sep 2024 17:58:07 +0200 Subject: [PATCH] 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. --- src/mod_pubsub.erl | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index d65c93f0f..e870596e7 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -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()].