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).
should_archive(#xmlel{name = <<"message">>} = Pkt, LServer) ->
case fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
<<"error">> ->
case is_resent(Pkt, LServer) of
true ->
false;
<<"groupchat">> ->
false;
<<"headline">> ->
false;
_ ->
case is_resent(Pkt, LServer) of
true ->
false ->
case {check_store_hint(Pkt),
fxml:get_attr_s(<<"type">>, Pkt#xmlel.attrs)} of
{_Hint, <<"error">>} ->
false;
false ->
case check_store_hint(Pkt) of
store ->
true;
no_store ->
{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
false;
none ->
case fxml:get_subtag_cdata(Pkt, <<"body">>) of
<<>> ->
%% Empty body
false;
_ ->
true
end
_ ->
true
end
end
end;

View File

@ -437,35 +437,36 @@ 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 ->
case has_offline_tag(Packet) of
false ->
case {check_store_hint(Packet),
fxml:get_tag_attr_s(<<"type">>, Packet)} of
{_Hint, <<"error">>} ->
false;
{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;
no_store ->
false;
none ->
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
false ->
fxml:get_subtag(Packet, <<"body">>) /= false;
unless_chat_state ->
not jlib:is_standalone_chat_state(Packet);
true ->
true
end
end;
true ->
false
false ->
fxml:get_subtag(Packet, <<"body">>) /= false;
unless_chat_state ->
not jlib:is_standalone_chat_state(Packet)
end
end;
true ->
true ->
false
end.