diff --git a/src/mod_mam.erl b/src/mod_mam.erl index 54572fb09..dba8b1cbf 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -34,8 +34,8 @@ -export([start/2, stop/1]). -export([user_send_packet/4, user_receive_packet/5, - process_iq_v0_2/3, process_iq_v0_3/3, remove_user/2, - remove_user/3, mod_opt_type/1, muc_process_iq/4, + process_iq_v0_2/3, process_iq_v0_3/3, disco_sm_features/5, + remove_user/2, remove_user/3, mod_opt_type/1, muc_process_iq/4, muc_filter_message/5]). -include_lib("stdlib/include/ms_transform.hrl"). @@ -88,6 +88,8 @@ start(Host, Opts) -> muc_filter_message, 50), ejabberd_hooks:add(muc_process_iq, Host, ?MODULE, muc_process_iq, 50), + ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, + disco_sm_features, 50), ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50), ejabberd_hooks:add(anonymous_purge_hook, Host, ?MODULE, @@ -130,6 +132,8 @@ stop(Host) -> gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MAM_0), gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_MAM_1), gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_MAM_1), + ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, + disco_sm_features, 50), ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50), ejabberd_hooks:delete(anonymous_purge_hook, Host, @@ -276,6 +280,15 @@ get_xdata_fields(SubEl) -> [] end. +disco_sm_features(empty, From, To, Node, Lang) -> + disco_sm_features({result, []}, From, To, Node, Lang); +disco_sm_features({result, OtherFeatures}, + #jid{luser = U, lserver = S}, + #jid{luser = U, lserver = S}, <<>>, _Lang) -> + {result, [?NS_MAM_TMP, ?NS_MAM_0, ?NS_MAM_1 | OtherFeatures]}; +disco_sm_features(Acc, _From, _To, _Node, _Lang) -> + Acc. + %%%=================================================================== %%% Internal functions %%%=================================================================== diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index dd7f78163..1606b593a 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -4144,6 +4144,13 @@ process_iq_disco_info(_From, get, Lang, StateData) -> <<"muc_moderated">>, <<"muc_unmoderated">>), ?CONFIG_OPT_TO_FEATURE((Config#config.password_protected), <<"muc_passwordprotected">>, <<"muc_unsecured">>)] + ++ case {gen_mod:is_loaded(StateData#state.server_host, mod_mam), + Config#config.mam} of + {true, true} -> + [?FEATURE(?NS_MAM_0)]; + _ -> + [] + end ++ iq_disco_info_extras(Lang, StateData), StateData}.