25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

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.
This commit is contained in:
Holger Weiss 2017-11-15 00:30:38 +01:00
parent 2b3890f1b0
commit 98419c6662

View File

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