diff --git a/src/mod_mam.erl b/src/mod_mam.erl index bbe279cb9..af4245f90 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -34,7 +34,8 @@ -export([user_send_packet/4, user_receive_packet/5, process_iq_v0_2/3, process_iq_v0_3/3, remove_user/2, - mod_opt_type/1, muc_process_iq/4, muc_filter_message/5]). + remove_user/3, mod_opt_type/1, muc_process_iq/4, + muc_filter_message/5]). -include_lib("stdlib/include/ms_transform.hrl"). -include("jlib.hrl"). diff --git a/src/mod_muc.erl b/src/mod_muc.erl index 725051e66..e68472a29 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -200,13 +200,16 @@ forget_room(ServerHost, Host, Name) -> forget_room(LServer, Host, Name, gen_mod:db_type(LServer, ?MODULE)). -forget_room(_LServer, Host, Name, mnesia) -> +forget_room(LServer, Host, Name, mnesia) -> + remove_room_mam(LServer, Host, Name), F = fun () -> mnesia:delete({muc_room, {Name, Host}}) end, mnesia:transaction(F); -forget_room(_LServer, Host, Name, riak) -> +forget_room(LServer, Host, Name, riak) -> + remove_room_mam(LServer, Host, Name), {atomic, ejabberd_riak:delete(muc_room, {Name, Host})}; forget_room(LServer, Host, Name, odbc) -> + remove_room_mam(LServer, Host, Name), SName = ejabberd_odbc:escape(Name), SHost = ejabberd_odbc:escape(Host), F = fun () -> @@ -216,6 +219,22 @@ forget_room(LServer, Host, Name, odbc) -> end, ejabberd_odbc:sql_transaction(LServer, F). +remove_room_mam(LServer, Host, Name) -> + case gen_mod:is_loaded(LServer, mod_mam) of + true -> + U = jlib:nodeprep(Name), + S = jlib:nameprep(Host), + DBType = gen_mod:db_type(LServer, mod_mam), + if DBType == odbc -> + mod_mam:remove_user(jlib:jid_to_string({U, S, <<>>}), + LServer, DBType); + true -> + mod_mam:remove_user(U, S, DBType) + end; + false -> + ok + end. + process_iq_disco_items(Host, From, To, #iq{lang = Lang} = IQ) -> Rsm = jlib:rsm_decode(IQ),