From 3bfa683586e6dc46416a9510e3181277874a8eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Fri, 20 Apr 2018 13:36:54 +0200 Subject: [PATCH] Fix mnesia call in mam archive management function --- src/mod_mam.erl | 4 ++++ src/mod_mam_mnesia.erl | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mod_mam.erl b/src/mod_mam.erl index 7912be30d..791bcd16f 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -259,6 +259,8 @@ remove_room(LServer, Name, Host) -> Mod:remove_room(LServer, LName, LHost), ok. +-spec remove_mam_for_user(binary(), binary()) -> + {ok, binary()} | {error, binary()}. remove_mam_for_user(User, Server) -> LUser = jid:nodeprep(User), LServer = jid:nameprep(Server), @@ -272,6 +274,8 @@ remove_mam_for_user(User, Server) -> {error, <<"Db returned error">>} end. +-spec remove_mam_for_user_with_peer(binary(), binary(), binary()) -> + {ok, binary()} | {error, binary()}. remove_mam_for_user_with_peer(User, Server, Peer) -> LUser = jid:nodeprep(User), LServer = jid:nameprep(Server), diff --git a/src/mod_mam_mnesia.erl b/src/mod_mam_mnesia.erl index 53d390cb7..55154f6bb 100644 --- a/src/mod_mam_mnesia.erl +++ b/src/mod_mam_mnesia.erl @@ -77,8 +77,7 @@ remove_from_archive(LUser, LServer, WithJid) -> US = {LUser, LServer}, Peer = jid:remove_resource(jid:split(WithJid)), F = fun () -> - Msgs = mnesia:match_object(archive_msg, - #archive_msg{us = US, bare_peer = Peer, _ = '_'}), + Msgs = mnesia:match_object(#archive_msg{us = US, bare_peer = Peer, _ = '_'}), lists:foreach(fun mnesia:delete_object/1, Msgs) end, case mnesia:transaction(F) of