mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Honor <store/> hint for any non-"error" message
XEP-0334 says: "A message containing the <store/> hint that is not of type 'error' SHOULD be stored by the entity."
This commit is contained in:
parent
28dde294e5
commit
bf9d6b5534
@ -555,24 +555,23 @@ parse_query_v0_2(Query) ->
|
||||
end, Query#xmlel.children).
|
||||
|
||||
should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
|
||||
case fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
|
||||
<<"error">> ->
|
||||
false;
|
||||
<<"groupchat">> ->
|
||||
false;
|
||||
<<"headline">> ->
|
||||
false;
|
||||
_ ->
|
||||
case is_resent(Pkt, LServer) of
|
||||
true ->
|
||||
false;
|
||||
false ->
|
||||
case check_store_hint(Pkt) of
|
||||
store ->
|
||||
true;
|
||||
no_store ->
|
||||
case {check_store_hint(Pkt),
|
||||
fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs)} of
|
||||
{_Hint, <<"error">>} ->
|
||||
false;
|
||||
none ->
|
||||
{store, _Type} ->
|
||||
true;
|
||||
{no_store, _Type} ->
|
||||
false;
|
||||
{none, <<"groupchat">>} ->
|
||||
false;
|
||||
{none, <<"headline">>} ->
|
||||
false;
|
||||
{none, _Type} ->
|
||||
case fxml:get_subtag_cdata(Pkt, <<"body">>) of
|
||||
<<>> ->
|
||||
%% Empty body
|
||||
@ -581,7 +580,6 @@ should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end;
|
||||
should_archive(#xmlel{}, _LServer) ->
|
||||
false.
|
||||
|
@ -437,36 +437,37 @@ remove_msg_by_node(To, Seq) ->
|
||||
end.
|
||||
|
||||
need_to_store(LServer, Packet) ->
|
||||
Type = fxml:get_tag_attr_s(<<"type">>, Packet),
|
||||
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
||||
and (Type /= <<"headline">>) ->
|
||||
case has_offline_tag(Packet) of
|
||||
false ->
|
||||
case check_store_hint(Packet) of
|
||||
store ->
|
||||
true;
|
||||
no_store ->
|
||||
case {check_store_hint(Packet),
|
||||
fxml:get_tag_attr_s(<<"type">>, Packet)} of
|
||||
{_Hint, <<"error">>} ->
|
||||
false;
|
||||
none ->
|
||||
{store, _Type} ->
|
||||
true;
|
||||
{no_store, _Type} ->
|
||||
false;
|
||||
{none, <<"groupchat">>} ->
|
||||
false;
|
||||
{none, <<"headline">>} ->
|
||||
false;
|
||||
{none, _Type} ->
|
||||
case gen_mod:get_module_opt(
|
||||
LServer, ?MODULE, store_empty_body,
|
||||
fun(V) when is_boolean(V) -> V;
|
||||
(unless_chat_state) -> unless_chat_state
|
||||
end,
|
||||
unless_chat_state) of
|
||||
true ->
|
||||
true;
|
||||
false ->
|
||||
fxml:get_subtag(Packet, <<"body">>) /= false;
|
||||
unless_chat_state ->
|
||||
not jlib:is_standalone_chat_state(Packet);
|
||||
true ->
|
||||
true
|
||||
not jlib:is_standalone_chat_state(Packet)
|
||||
end
|
||||
end;
|
||||
true ->
|
||||
false
|
||||
end;
|
||||
true ->
|
||||
false
|
||||
end.
|
||||
|
||||
store_packet(From, To, Packet) ->
|
||||
|
Loading…
Reference in New Issue
Block a user