mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
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.
This commit is contained in:
parent
5c3074c0fb
commit
60803f5780
21
src/jlib.erl
21
src/jlib.erl
@ -574,14 +574,19 @@ unwrap_carbon(Stanza, Direction) ->
|
|||||||
|
|
||||||
-spec is_standalone_chat_state(xmlel()) -> boolean().
|
-spec is_standalone_chat_state(xmlel()) -> boolean().
|
||||||
|
|
||||||
is_standalone_chat_state(#xmlel{name = <<"message">>, children = Els}) ->
|
is_standalone_chat_state(Stanza) ->
|
||||||
IgnoreNS = [?NS_CHATSTATES, ?NS_DELAY],
|
case unwrap_carbon(Stanza) of
|
||||||
Stripped = [El || #xmlel{name = Name, attrs = Attrs} = El <- Els,
|
#xmlel{name = <<"message">>, children = Els} ->
|
||||||
not lists:member(fxml:get_attr_s(<<"xmlns">>, Attrs),
|
IgnoreNS = [?NS_CHATSTATES, ?NS_DELAY],
|
||||||
IgnoreNS),
|
Stripped = [El || #xmlel{name = Name, attrs = Attrs} = El <- Els,
|
||||||
Name /= <<"thread">>],
|
not lists:member(fxml:get_attr_s(<<"xmlns">>,
|
||||||
Stripped == [];
|
Attrs),
|
||||||
is_standalone_chat_state(_El) -> false.
|
IgnoreNS),
|
||||||
|
Name /= <<"thread">>],
|
||||||
|
Stripped == [];
|
||||||
|
#xmlel{} ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
-spec add_delay_info(xmlel(), jid() | ljid() | binary(), erlang:timestamp())
|
-spec add_delay_info(xmlel(), jid() | ljid() | binary(), erlang:timestamp())
|
||||||
-> xmlel().
|
-> xmlel().
|
||||||
|
@ -165,7 +165,7 @@ filter_presence(Acc, _Host, _Stanza) -> Acc.
|
|||||||
|
|
||||||
filter_chat_states({C2SState, _OutStanzas} = Acc, Host,
|
filter_chat_states({C2SState, _OutStanzas} = Acc, Host,
|
||||||
#xmlel{name = <<"message">>} = Stanza) ->
|
#xmlel{name = <<"message">>} = Stanza) ->
|
||||||
case jlib:is_standalone_chat_state(jlib:unwrap_carbon(Stanza)) of
|
case jlib:is_standalone_chat_state(Stanza) of
|
||||||
true ->
|
true ->
|
||||||
From = fxml:get_tag_attr_s(<<"from">>, Stanza),
|
From = fxml:get_tag_attr_s(<<"from">>, Stanza),
|
||||||
To = fxml:get_tag_attr_s(<<"to">>, Stanza),
|
To = fxml:get_tag_attr_s(<<"to">>, Stanza),
|
||||||
|
@ -455,8 +455,7 @@ need_to_store(LServer, Packet) ->
|
|||||||
false ->
|
false ->
|
||||||
fxml:get_subtag(Packet, <<"body">>) /= false;
|
fxml:get_subtag(Packet, <<"body">>) /= false;
|
||||||
unless_chat_state ->
|
unless_chat_state ->
|
||||||
not jlib:is_standalone_chat_state(
|
not jlib:is_standalone_chat_state(Packet);
|
||||||
jlib:unwrap_carbon(Packet));
|
|
||||||
true ->
|
true ->
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user