-spec is_standalone_chat_state(xmlel()) -> boolean().
-is_standalone_chat_state(#xmlel{name = <<"message">>, children = Els}) ->
- IgnoreNS = [?NS_CHATSTATES, ?NS_DELAY],
- Stripped = [El || #xmlel{name = Name, attrs = Attrs} = El <- Els,
- not lists:member(fxml:get_attr_s(<<"xmlns">>, Attrs),
- IgnoreNS),
- Name /= <<"thread">>],
- Stripped == [];
-is_standalone_chat_state(_El) -> false.
+is_standalone_chat_state(Stanza) ->
+ case unwrap_carbon(Stanza) of
+ #xmlel{name = <<"message">>, children = Els} ->
+ IgnoreNS = [?NS_CHATSTATES, ?NS_DELAY],
+ Stripped = [El || #xmlel{name = Name, attrs = Attrs} = El <- Els,
+ not lists:member(fxml:get_attr_s(<<"xmlns">>,
+ Attrs),
+ IgnoreNS),
+ Name /= <<"thread">>],
+ Stripped == [];
+ #xmlel{} ->
+ false
+ end.
-spec add_delay_info(xmlel(), jid() | ljid() | binary(), erlang:timestamp())
-> xmlel().
filter_chat_states({C2SState, _OutStanzas} = Acc, Host,
#xmlel{name = <<"message">>} = Stanza) ->
- case jlib:is_standalone_chat_state(jlib:unwrap_carbon(Stanza)) of
+ case jlib:is_standalone_chat_state(Stanza) of
true ->
From = fxml:get_tag_attr_s(<<"from">>, Stanza),
To = fxml:get_tag_attr_s(<<"to">>, Stanza),
false ->
fxml:get_subtag(Packet, <<"body">>) /= false;
unless_chat_state ->
- not jlib:is_standalone_chat_state(
- jlib:unwrap_carbon(Packet));
+ not jlib:is_standalone_chat_state(Packet);
true ->
true
end