mod_mam: Don't store resent messages

Make sure messages that were resent by the stream management code aren't
stored in MAM.
This commit is contained in:
Holger Weiss 2015-12-09 22:44:45 +01:00
parent e09afe367f
commit 469e93f37b
1 changed files with 23 additions and 10 deletions

View File

@ -363,18 +363,23 @@ should_archive(#xmlel{name = <<"message">>} = Pkt) ->
<<"groupchat">> ->
false;
_ ->
case check_store_hint(Pkt) of
store ->
true;
no_store ->
case is_resent(Pkt) of
true ->
false;
none ->
case xml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> ->
%% Empty body
false ->
case check_store_hint(Pkt) of
store ->
true;
no_store ->
false;
_ ->
true
none ->
case xml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> ->
%% Empty body
false;
_ ->
true
end
end
end
end;
@ -458,6 +463,14 @@ has_no_store_hint(Message) ->
xml:get_subtag_with_xmlns(Message, <<"no-permanent-storage">>, ?NS_HINTS)
/= false.
is_resent(Pkt) ->
case xml:get_subtag_cdata(Pkt, <<"delay">>) of
<<>> ->
false;
Desc ->
binary:match(Desc, <<"Resent">>) =/= nomatch
end.
store_msg(C2SState, Pkt, LUser, LServer, Peer, Dir) ->
Prefs = get_prefs(LUser, LServer),
case should_archive_peer(C2SState, Prefs, Peer) of