aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2017-11-15 19:04:47 +0100
committerChristophe Romain <christophe.romain@process-one.net>2017-11-15 19:04:47 +0100
commit62aab0fce4031f1296da9b1ba2682d6d7dbe3b59 (patch)
tree255956e6c947adc1702b0e84cff0eb019913054a
parentCleanup pubsub subscriptions quering, fix pep case (diff)
Fix select_type race on plugin_init
-rw-r--r--src/mod_pubsub.erl30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index c7e433d46..17a2f1e57 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -3075,7 +3075,7 @@ get_configure(Host, ServerHost, Node, From, Lang) ->
-spec get_default(host(), binary(), jid(), binary()) -> {result, pubsub_owner()}.
get_default(Host, Node, _From, Lang) ->
- Type = select_type(Host, Host, Node),
+ Type = select_type(serverhost(Host), Host, Node),
Options = node_options(Host, Type),
Fs = get_configure_xfields(Type, Options, Lang, []),
{result, #pubsub_owner{default = {<<>>, #xdata{type = form, fields = Fs}}}}.
@@ -3415,20 +3415,20 @@ config(ServerHost, Key, Default) ->
end.
-spec select_type(binary(), host(), binary(), binary()) -> binary().
-select_type(ServerHost, Host, Node, Type) ->
- SelectedType = case Host of
- {_User, _Server, _Resource} ->
- case config(ServerHost, pep_mapping) of
- undefined -> ?PEPNODE;
- Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE)
- end;
- _ ->
- Type
- end,
- ConfiguredTypes = plugins(Host),
- case lists:member(SelectedType, ConfiguredTypes) of
- true -> SelectedType;
- false -> hd(ConfiguredTypes)
+select_type(ServerHost, {_User, _Server, _Resource}, Node, _Type) ->
+ case config(ServerHost, pep_mapping) of
+ undefined -> ?PEPNODE;
+ Mapping -> proplists:get_value(Node, Mapping, ?PEPNODE)
+ end;
+select_type(ServerHost, _Host, _Node, Type) ->
+ case config(ServerHost, plugins) of
+ undefined ->
+ Type;
+ Plugins ->
+ case lists:member(Type, Plugins) of
+ true -> Type;
+ false -> hd(Plugins)
+ end
end.
-spec select_type(binary(), host(), binary()) -> binary().