25
1
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:
Holger Weiss 2016-08-12 21:13:10 +02:00
parent 28dde294e5
commit bf9d6b5534
2 changed files with 48 additions and 49 deletions

View File

@ -555,31 +555,29 @@ parse_query_v0_2(Query) ->
end, Query#xmlel.children). end, Query#xmlel.children).
should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) -> should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
case fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of case is_resent(Pkt, LServer) of
<<"error">> -> true ->
false; false;
<<"groupchat">> -> false ->
false; case {check_store_hint(Pkt),
<<"headline">> -> fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs)} of
false; {_Hint, <<"error">>} ->
_ ->
case is_resent(Pkt, LServer) of
true ->
false; false;
false -> {store, _Type} ->
case check_store_hint(Pkt) of true;
store -> {no_store, _Type} ->
true; false;
no_store -> {none, <<"groupchat">>} ->
false;
{none, <<"headline">>} ->
false;
{none, _Type} ->
case fxml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> ->
%% Empty body
false; false;
none -> _ ->
case fxml:get_subtag_cdata(Pkt, <<"body">>) of true
<<>> ->
%% Empty body
false;
_ ->
true
end
end end
end end
end; end;

View File

@ -437,35 +437,36 @@ remove_msg_by_node(To, Seq) ->
end. end.
need_to_store(LServer, Packet) -> need_to_store(LServer, Packet) ->
Type = fxml:get_tag_attr_s(<<"type">>, Packet), case has_offline_tag(Packet) of
if (Type /= <<"error">>) and (Type /= <<"groupchat">>) false ->
and (Type /= <<"headline">>) -> case {check_store_hint(Packet),
case has_offline_tag(Packet) of fxml:get_tag_attr_s(<<"type">>, Packet)} of
false -> {_Hint, <<"error">>} ->
case check_store_hint(Packet) of false;
store -> {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; true;
no_store -> false ->
false; fxml:get_subtag(Packet, <<"body">>) /= false;
none -> unless_chat_state ->
case gen_mod:get_module_opt( not jlib:is_standalone_chat_state(Packet)
LServer, ?MODULE, store_empty_body, end
fun(V) when is_boolean(V) -> V;
(unless_chat_state) -> unless_chat_state
end,
unless_chat_state) of
false ->
fxml:get_subtag(Packet, <<"body">>) /= false;
unless_chat_state ->
not jlib:is_standalone_chat_state(Packet);
true ->
true
end
end;
true ->
false
end; end;
true -> true ->
false false
end. end.