-define(STDTREE, "default").
-define(STDNODE, "default").
+-define(PEPNODE, "pep").
%% exports for hooks
-export([set_presence/4,
gen_mod:get_opt(nodetree, Opts, ?STDTREE)),
?INFO_MSG("** tree plugin is ~p",[TreePlugin]),
TreePlugin:init(Host, ServerHost, Opts),
- Plugins = lists:usort(gen_mod:get_opt(plugins, Opts, []) ++ [?STDNODE]),
+ Plugins = lists:usort(gen_mod:get_opt(plugins, Opts, []) ++ [?STDNODE,?PEPNODE]),
lists:foreach(fun(Name) ->
- ?INFO_MSG("** init ~s plugin~n",[Name]),
+ ?INFO_MSG("** init ~s plugin",[Name]),
Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name),
Plugin:init(Host, ServerHost, Opts)
end, Plugins),
terminate_plugins(Host, ServerHost, Plugins, TreePlugin) ->
lists:foreach(fun(Name) ->
- ?INFO_MSG("** terminate ~s plugin~n",[Name]),
+ ?INFO_MSG("** terminate ~s plugin",[Name]),
Plugin = list_to_atom(?PLUGIN_PREFIX++Name),
Plugin:terminate(Host, ServerHost)
end, Plugins),
end;
create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) ->
Type = case Host of
- {_User, _Server, _Resource} -> "pep";
+ {_User, _Server, _Resource} -> ?PEPNODE;
_ -> GivenType
end,
Parent = lists:sublist(Node, length(Node) - 1),
{error, ?ERR_ITEM_NOT_FOUND} ->
%% handles auto-create feature
%% for automatic node creation. we'll take the default node type:
- %% first listed into the plugins configuration option
- Type = case ets:lookup(gen_mod:get_module_proc(ServerHost, pubsub_state), plugins) of
- [{plugins, PL}] -> hd(PL);
- _ -> ?STDNODE
- end,
+ %% first listed into the plugins configuration option, or pep
+ Type = case Host of
+ {_User, _Server, _Resource} ->
+ ?PEPNODE;
+ _ ->
+ case ets:lookup(gen_mod:get_module_proc(ServerHost, pubsub_state), plugins) of
+ [{plugins, PL}] -> hd(PL);
+ _ -> ?STDNODE
+ end
+ end,
case lists:member("auto-create", features(Type)) of
true ->
case create_node(Host, ServerHost, Node, Publisher, Type) of
- {result, [CreateRes]} ->
- %% Ugly hack
- SNewNode = xml:get_path_s(
- CreateRes,
- [{elem, "create"},
- {attr, "node"}]),
- NewNode = string_to_node(SNewNode),
- if
- NewNode /= Node ->
- publish_item(Host, ServerHost, NewNode,
- Publisher, ItemId, Payload);
- true ->
- {error, ?ERR_ITEM_NOT_FOUND}
- end;
+ {result, _} ->
+ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload);
_ ->
{error, ?ERR_ITEM_NOT_FOUND}
end;