summaryrefslogtreecommitdiff
path: root/src/jlib.erl
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2016-06-05 22:36:56 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2016-06-05 22:36:56 +0200
commit60803f57802ecf460e25ce3a6ef5dc86285ed448 (patch)
tree8e17aa2b09b2d403087e58565801e599623912ed /src/jlib.erl
parentmod_client_state: Fix handling of chat states (diff)
Simplify check for carbon-copied chat states
Let jlib:is_standalone_chat_state/1 unwrap carbon copies rather than leaving this to the caller. We still export jlib:unwrap_carbon/1, as this function might also be useful for other purposes.
Diffstat (limited to 'src/jlib.erl')
-rw-r--r--src/jlib.erl21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/jlib.erl b/src/jlib.erl
index 42ac4bff..e5cba318 100644
--- a/src/jlib.erl
+++ b/src/jlib.erl
@@ -574,14 +574,19 @@ unwrap_carbon(Stanza, Direction) ->
-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().