mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
PubSub: fix node_options, default options only apply on first plugin
This commit is contained in:
parent
0cc1ae0a6a
commit
cf09ed2df2
@ -259,10 +259,9 @@ init([ServerHost, Opts]) ->
|
|||||||
end,
|
end,
|
||||||
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
|
||||||
DefaultModule = plugin(Host, hd(Plugins)),
|
DefaultModule = plugin(Host, hd(Plugins)),
|
||||||
BaseOptions = DefaultModule:options(),
|
DefaultNodeCfg = merge_config(
|
||||||
DefaultNodeCfg = filter_node_options(
|
|
||||||
gen_mod:get_opt(default_node_config, Opts, []),
|
gen_mod:get_opt(default_node_config, Opts, []),
|
||||||
BaseOptions),
|
DefaultModule:options()),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(H) ->
|
fun(H) ->
|
||||||
T = gen_mod:get_module_proc(H, config),
|
T = gen_mod:get_module_proc(H, config),
|
||||||
@ -3091,10 +3090,10 @@ 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) ->
|
||||||
case config(Host, default_node_config) of
|
DefaultOpts = node_plugin_options(Host, Type),
|
||||||
undefined -> node_plugin_options(Host, Type);
|
case config(Host, plugins) of
|
||||||
[] -> node_plugin_options(Host, Type);
|
[Type|_] -> config(Host, default_node_config, DefaultOpts);
|
||||||
Config -> Config
|
_ -> DefaultOpts
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec node_plugin_options(host(), binary()) -> [{atom(), any()}].
|
-spec node_plugin_options(host(), binary()) -> [{atom(), any()}].
|
||||||
@ -3108,13 +3107,6 @@ node_plugin_options(Host, Type) ->
|
|||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec filter_node_options([{atom(), any()}], [{atom(), any()}]) -> [{atom(), any()}].
|
|
||||||
filter_node_options(Options, BaseOptions) ->
|
|
||||||
lists:foldl(fun({Key, Val}, Acc) ->
|
|
||||||
DefaultValue = proplists:get_value(Key, Options, Val),
|
|
||||||
[{Key, DefaultValue}|Acc]
|
|
||||||
end, [], BaseOptions).
|
|
||||||
|
|
||||||
-spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].
|
-spec node_owners_action(host(), binary(), nodeIdx(), [ljid()]) -> [ljid()].
|
||||||
node_owners_action(Host, Type, Nidx, []) ->
|
node_owners_action(Host, Type, Nidx, []) ->
|
||||||
case node_action(Host, Type, get_node_affiliations, [Nidx]) of
|
case node_action(Host, Type, get_node_affiliations, [Nidx]) of
|
||||||
@ -3219,11 +3211,11 @@ set_configure(Host, Node, From, Config, Lang) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
-spec merge_config([proplists:property()], [proplists:property()]) -> [proplists:property()].
|
-spec merge_config([proplists:property()], [proplists:property()]) -> [proplists:property()].
|
||||||
merge_config(Config1, Config2) ->
|
merge_config(CustomConfig, DefaultConfig) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({Opt, Val}, Acc) ->
|
fun({Opt, Val}, Acc) ->
|
||||||
lists:keystore(Opt, 1, Acc, {Opt, Val})
|
lists:keystore(Opt, 1, Acc, {Opt, Val})
|
||||||
end, Config2, Config1).
|
end, DefaultConfig, CustomConfig).
|
||||||
|
|
||||||
-spec decode_node_config(undefined | xdata(), binary(), binary()) ->
|
-spec decode_node_config(undefined | xdata(), binary(), binary()) ->
|
||||||
pubsub_node_config:result() |
|
pubsub_node_config:result() |
|
||||||
|
Loading…
Reference in New Issue
Block a user