Advertise feature in disco info for account JID

As per XEP-0313 >= 0.2, advertise the MAM feature in the service
discovery information for the bare account JID.

Some clients check the server's discovery information instead, so we'll
continue to advertise the feature there as well (at least for the
moment).
This commit is contained in:
Holger Weiss 2015-04-26 17:16:52 +02:00
parent 73b984f193
commit eb52291ca1
1 changed files with 17 additions and 1 deletions

View File

@ -50,7 +50,8 @@
code_change/3]). code_change/3]).
%% ejabberd_hooks callbacks. %% ejabberd_hooks callbacks.
-export([receive_stanza/4, -export([disco_features/5,
receive_stanza/4,
send_stanza/3, send_stanza/3,
remove_user/2]). remove_user/2]).
@ -157,7 +158,9 @@ start(Host, Opts) ->
parallel), parallel),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM, ?MODULE, gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_MAM, ?MODULE,
handle_iq, IQDisc), handle_iq, IQDisc),
%% Set up MAM feature announcement.
mod_disco:register_feature(Host, ?NS_MAM), mod_disco:register_feature(Host, ?NS_MAM),
ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, disco_features, 50),
%% Set up message storage process. %% Set up message storage process.
Proc = gen_mod:get_module_proc(Host, ?PROCNAME), Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
Spec = {Proc, {?MODULE, start_link, [Host, Opts]}, permanent, 3000, worker, Spec = {Proc, {?MODULE, start_link, [Host, Opts]}, permanent, 3000, worker,
@ -167,6 +170,8 @@ start(Host, Opts) ->
-spec stop(binary()) -> ok. -spec stop(binary()) -> ok.
stop(Host) -> stop(Host) ->
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, disco_features, 50),
%% Stop message storage process.
Proc = gen_mod:get_module_proc(Host, ?PROCNAME), Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
ok = supervisor:terminate_child(ejabberd_sup, Proc), ok = supervisor:terminate_child(ejabberd_sup, Proc),
ok = supervisor:delete_child(ejabberd_sup, Proc). ok = supervisor:delete_child(ejabberd_sup, Proc).
@ -258,6 +263,17 @@ code_change(_OldVsn, #state{host = Host} = State, _Extra) ->
%% ejabberd_hooks callbacks. %% ejabberd_hooks callbacks.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
-spec disco_features(empty | {result, [binary()]}, jid(), jid(), binary(),
binary()) -> {result, [binary()]}.
disco_features(empty, From, To, Node, Lang) ->
disco_features({result, []}, From, To, Node, Lang);
disco_features({result, OtherFeatures},
#jid{luser = U, lserver = S},
#jid{luser = U, lserver = S}, <<"">>, _Lang) ->
{result, OtherFeatures ++ [?NS_MAM]};
disco_features(Acc, _From, _To, _Node, _Lang) -> Acc.
-spec receive_stanza(jid(), jid(), jid(), xmlel()) -> ok. -spec receive_stanza(jid(), jid(), jid(), xmlel()) -> ok.
receive_stanza(#jid{luser = U, lserver = S} = JID, From, To, receive_stanza(#jid{luser = U, lserver = S} = JID, From, To,