mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
mod_mam: Honor Message Processing Hints (XEP-0334)
This commit is contained in:
parent
3e57850da7
commit
5ce0b062ff
|
@ -361,17 +361,26 @@ process_iq(LServer, From, To, IQ, SubEl, Fs, MsgType) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
should_archive(#xmlel{name = <<"message">>} = Pkt) ->
|
should_archive(#xmlel{name = <<"message">>} = Pkt) ->
|
||||||
case {xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs),
|
case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
|
||||||
xml:get_subtag_cdata(Pkt, <<"body">>)} of
|
<<"error">> ->
|
||||||
{<<"error">>, _} ->
|
|
||||||
false;
|
false;
|
||||||
{<<"groupchat">>, _} ->
|
<<"groupchat">> ->
|
||||||
false;
|
|
||||||
{_, <<>>} ->
|
|
||||||
%% Empty body
|
|
||||||
false;
|
false;
|
||||||
_ ->
|
_ ->
|
||||||
true
|
case check_store_hint(Pkt) of
|
||||||
|
store ->
|
||||||
|
true;
|
||||||
|
no_store ->
|
||||||
|
false;
|
||||||
|
none ->
|
||||||
|
case xml:get_subtag_cdata(Pkt, <<"body">>) of
|
||||||
|
<<>> ->
|
||||||
|
%% Empty body
|
||||||
|
false;
|
||||||
|
_ ->
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
end;
|
end;
|
||||||
should_archive(#xmlel{}) ->
|
should_archive(#xmlel{}) ->
|
||||||
false.
|
false.
|
||||||
|
@ -426,6 +435,33 @@ should_archive_muc(_MUCState, _Peer) ->
|
||||||
%% TODO
|
%% TODO
|
||||||
true.
|
true.
|
||||||
|
|
||||||
|
check_store_hint(Pkt) ->
|
||||||
|
case has_store_hint(Pkt) of
|
||||||
|
true ->
|
||||||
|
store;
|
||||||
|
false ->
|
||||||
|
case has_no_store_hint(Pkt) of
|
||||||
|
true ->
|
||||||
|
no_store;
|
||||||
|
false ->
|
||||||
|
none
|
||||||
|
end
|
||||||
|
end.
|
||||||
|
|
||||||
|
has_store_hint(Message) ->
|
||||||
|
xml:get_subtag_with_xmlns(Message, <<"store">>, ?NS_HINTS)
|
||||||
|
/= false.
|
||||||
|
|
||||||
|
has_no_store_hint(Message) ->
|
||||||
|
xml:get_subtag_with_xmlns(Message, <<"no-store">>, ?NS_HINTS)
|
||||||
|
/= false orelse
|
||||||
|
xml:get_subtag_with_xmlns(Message, <<"no-storage">>, ?NS_HINTS)
|
||||||
|
/= false orelse
|
||||||
|
xml:get_subtag_with_xmlns(Message, <<"no-permanent-store">>, ?NS_HINTS)
|
||||||
|
/= false orelse
|
||||||
|
xml:get_subtag_with_xmlns(Message, <<"no-permanent-storage">>, ?NS_HINTS)
|
||||||
|
/= false.
|
||||||
|
|
||||||
store_msg(C2SState, Pkt, LUser, LServer, Peer, Dir) ->
|
store_msg(C2SState, Pkt, LUser, LServer, Peer, Dir) ->
|
||||||
Prefs = get_prefs(LUser, LServer),
|
Prefs = get_prefs(LUser, LServer),
|
||||||
case should_archive_peer(C2SState, Prefs, Peer) of
|
case should_archive_peer(C2SState, Prefs, Peer) of
|
||||||
|
|
Loading…
Reference in New Issue
Block a user