From 98419c666215e1cc804457341e1e4764e0a8413a Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 15 Nov 2017 00:30:38 +0100 Subject: [PATCH] mod_mam: Improve handling of forked messages Make sure a message that was forked in ejabberd_sm will really only be tagged with a stanza ID if (another copy of) it was stored in MAM. --- src/mod_mam.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mod_mam.erl b/src/mod_mam.erl index 3d3d9a2bc..6c6a15ca1 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -755,12 +755,12 @@ may_enter_room(From, MUCState) -> -spec store_msg(message(), binary(), binary(), jid(), send | recv) -> ok | pass | any(). -store_msg(#message{meta = #{sm_copy := true}}, _LUser, _LServer, _Peer, _Dir) -> - ok; % Already stored. store_msg(Pkt, LUser, LServer, Peer, Dir) -> Prefs = get_prefs(LUser, LServer), - case should_archive_peer(LUser, LServer, Prefs, Peer) of - true -> + case {should_archive_peer(LUser, LServer, Prefs, Peer), Pkt} of + {true, #message{meta = #{sm_copy := true}}} -> + ok; % Already stored. + {true, _} -> case ejabberd_hooks:run_fold(store_mam_message, LServer, Pkt, [LUser, LServer, Peer, chat, Dir]) of drop -> @@ -772,7 +772,7 @@ store_msg(Pkt, LUser, LServer, Peer, Dir) -> Mod = gen_mod:db_mod(LServer, ?MODULE), Mod:store(El, LServer, US, chat, Peer, <<"">>, Dir, ID) end; - false -> + {false, _} -> pass end.