26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Remove MAM archives on MUC room destroy

This commit is contained in:
Evgeniy Khramtsov 2015-08-19 16:15:02 +03:00
parent 247bd9eae5
commit 94444c87e8
2 changed files with 23 additions and 3 deletions

View File

@ -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").

View File

@ -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),