Skip to content

Commit

Permalink
mod_pubsub: Fall back to default plugin options
Browse files Browse the repository at this point in the history
If the plugin handling a node creation request isn't enabled, fall back
to applying the default plugin (currently node_flat) options.
  • Loading branch information
weiss committed Sep 28, 2024
1 parent a9583b4 commit 36187e0
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/mod_pubsub.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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()].
Expand Down

0 comments on commit 36187e0

Please sign in to comment.