25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

add condition inclusion of pep in disco identity (EJAB-564)

SVN Revision: 1268
This commit is contained in:
Christophe Romain 2008-04-02 09:06:28 +00:00
parent 39b35cf54b
commit 37fc28ef49
2 changed files with 30 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2008-04-02 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: add condition inclusion of pep in
disco identity (EJAB-564)
2008-04-01 Badlop <badlop@process-one.net> 2008-04-01 Badlop <badlop@process-one.net>
* doc/guide.tex: Updated command line parameters, epmd section * doc/guide.tex: Updated command line parameters, epmd section

View File

@ -114,7 +114,7 @@
host, host,
access, access,
nodetree = ?STDTREE, nodetree = ?STDTREE,
plugins = [?STDNODE,?PEPNODE]}). plugins = [?STDNODE]}).
%%==================================================================== %%====================================================================
%% API %% API
@ -208,7 +208,7 @@ init_plugins(Host, ServerHost, Opts) ->
gen_mod:get_opt(nodetree, Opts, ?STDTREE)), gen_mod:get_opt(nodetree, Opts, ?STDTREE)),
?INFO_MSG("** tree plugin is ~p",[TreePlugin]), ?INFO_MSG("** tree plugin is ~p",[TreePlugin]),
TreePlugin:init(Host, ServerHost, Opts), TreePlugin:init(Host, ServerHost, Opts),
Plugins = lists:usort(gen_mod:get_opt(plugins, Opts, []) ++ [?STDNODE,?PEPNODE]), Plugins = lists:usort(gen_mod:get_opt(plugins, Opts, []) ++ [?STDNODE]),
lists:foreach(fun(Name) -> lists:foreach(fun(Name) ->
?INFO_MSG("** init ~s plugin",[Name]), ?INFO_MSG("** init ~s plugin",[Name]),
Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name), Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name),
@ -303,8 +303,15 @@ update_database(Host) ->
%% disco hooks handling functions %% disco hooks handling functions
%% %%
disco_local_identity(Acc, _From, _To, [], _Lang) -> identity(Host) ->
Acc ++ [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []} ]; Identity = case lists:member(?PEPNODE, plugins(Host)) of
true -> [{"category", "pubsub"}, {"type", "pep"}];
false -> [{"category", "pubsub"}]
end,
{xmlelement, "identity", Identity, []}.
disco_local_identity(Acc, _From, To, [], _Lang) ->
Acc ++ [identity(To#jid.lserver)];
disco_local_identity(Acc, _From, _To, _Node, _Lang) -> disco_local_identity(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
@ -325,8 +332,8 @@ disco_local_items(Acc, _From, _To, [], _Lang) ->
disco_local_items(Acc, _From, _To, _Node, _Lang) -> disco_local_items(Acc, _From, _To, _Node, _Lang) ->
Acc. Acc.
disco_sm_identity(Acc, _From, _To, [], _Lang) -> disco_sm_identity(Acc, _From, To, [], _Lang) ->
Acc ++ [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []} ]; Acc ++ [identity(To#jid.lserver)];
disco_sm_identity(Acc, From, To, Node, _Lang) -> disco_sm_identity(Acc, From, To, Node, _Lang) ->
LOwner = jlib:jid_tolower(jlib:jid_remove_resource(To)), LOwner = jlib:jid_tolower(jlib:jid_remove_resource(To)),
Acc ++ case node_disco_identity(LOwner, From, Node) of Acc ++ case node_disco_identity(LOwner, From, Node) of
@ -829,11 +836,7 @@ iq_get_vcard(Lang) ->
"\nCopyright (c) 2004-2008 Process-One"}]}]. "\nCopyright (c) 2004-2008 Process-One"}]}].
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang) -> iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang) ->
Plugins = case ets:lookup(gen_mod:get_module_proc(ServerHost, pubsub_state), plugins) of iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, all, plugins(ServerHost)).
[{plugins, PL}] -> PL;
_ -> [?STDNODE,?PEPNODE]
end,
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, all, Plugins).
iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) -> iq_pubsub(Host, ServerHost, From, IQType, SubEl, _Lang, Access, Plugins) ->
{xmlelement, _, _, SubEls} = SubEl, {xmlelement, _, _, SubEls} = SubEl,
@ -1474,10 +1477,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
{_User, _Server, _Resource} -> {_User, _Server, _Resource} ->
?PEPNODE; ?PEPNODE;
_ -> _ ->
case ets:lookup(gen_mod:get_module_proc(ServerHost, pubsub_state), plugins) of hd(plugins(ServerHost))
[{plugins, PL}] -> hd(PL);
_ -> ?STDNODE
end
end, end,
case lists:member("auto-create", features(Type)) of case lists:member("auto-create", features(Type)) of
true -> true ->
@ -2598,6 +2598,12 @@ set_xoption([_ | _Opts], _NewOpts) ->
%%%% plugin handling %%%% plugin handling
plugins(Host) ->
case ets:lookup(gen_mod:get_module_proc(Host, pubsub_state), plugins) of
[{plugins, PL}] -> PL;
_ -> [?STDNODE]
end.
features() -> features() ->
[ [
%"access-authorize", % OPTIONAL %"access-authorize", % OPTIONAL
@ -2649,8 +2655,10 @@ features(Type) ->
{'EXIT', {undef, _}} -> []; {'EXIT', {undef, _}} -> [];
Result -> Result Result -> Result
end. end.
features(_Host, []) -> features(Host, []) ->
lists:usort(features(?STDNODE) ++ features(?PEPNODE)); lists:usort(lists:foldl(fun(Plugin, Acc) ->
Acc ++ features(Plugin)
end, [], plugins(Host)));
features(Host, Node) -> features(Host, Node) ->
{result, Features} = node_action(Host, Node, features, []), {result, Features} = node_action(Host, Node, features, []),
lists:usort(features() ++ Features). lists:usort(features() ++ Features).