25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Fix dialyzer warnings

This commit is contained in:
Paweł Chmielowski 2024-09-02 12:42:55 +02:00
parent 017b2feac1
commit b455d93c69

View File

@ -166,17 +166,20 @@ handle_event({new_shaper, Shaper}, StateName, #state{ws = {_, WsPid}} = StateDat
handle_sync_event({send_xml, Packet}, _From, StateName,
#state{ws = {_, WsPid}} = StateData) ->
Packet2 = case Packet of
SN2 = case Packet of
{xmlstreamstart, _, Attrs} ->
Attrs2 = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>} |
lists:keydelete(<<"xmlns">>, 1, lists:keydelete(<<"xmlns:stream">>, 1, Attrs))],
{xmlstreamelement, #xmlel{name = <<"open">>, attrs = Attrs2}};
route_el(WsPid, #xmlel{name = <<"open">>, attrs = Attrs2}),
StateName;
{xmlstreamend, _} ->
{xmlstreamelement, #xmlel{name = <<"close">>,
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}};
{xmlstreamraw, <<"\r\n\r\n">>} -> % cdata ping
skip;
{xmlstreamelement, #xmlel{name=Name2} = El2} ->
route_el(WsPid, #xmlel{name = <<"close">>,
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}),
stream_end_sent;
{xmlstreamraw, <<"\r\n\r\n">>} ->
% cdata ping
StateName;
{xmlstreamelement, #xmlel{name = Name2} = El2} ->
El3 = case Name2 of
<<"stream:", _/binary>> ->
fxml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2);
@ -188,27 +191,7 @@ handle_sync_event({send_xml, Packet}, _From, StateName,
El2
end
end,
{xmlstreamelement, El3}
end,
case Packet2 of
{xmlstreamstart, Name, Attrs3} ->
B = fxml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}),
route_text(WsPid, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>);
{xmlstreamend, Name} ->
route_text(WsPid, <<"</", Name/binary, ">">>);
{xmlstreamelement, El} ->
route_text(WsPid, fxml:element_to_binary(El));
{xmlstreamraw, Bin} ->
route_text(WsPid, Bin);
{xmlstreamcdata, Bin2} ->
route_text(WsPid, Bin2);
skip ->
ok
end,
SN2 = case Packet2 of
{xmlstreamelement, #xmlel{name = <<"close">>}} ->
stream_end_sent;
_ ->
route_el(WsPid, El3),
StateName
end,
{reply, ok, SN2, StateData};
@ -217,6 +200,8 @@ handle_sync_event(close, _From, StateName, #state{ws = {_, WsPid}} = StateData)
Close = #xmlel{name = <<"close">>,
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
route_text(WsPid, fxml:element_to_binary(Close)),
{stop, normal, StateData};
handle_sync_event(close, _From, _StateName, StateData) ->
{stop, normal, StateData}.
handle_info(closed, _StateName, StateData) ->
@ -225,7 +210,7 @@ handle_info({received, Packet}, StateName, StateDataI) ->
{StateData, Parsed} = parse(StateDataI, Packet),
SD = case StateData#state.active of
false ->
Input = StateData#state.input ++ if is_binary(Parsed) -> [Parsed]; true -> Parsed end,
Input = StateData#state.input ++ Parsed,
StateData#state{input = Input};
true ->
StateData#state.c2s_pid ! {tcp, StateData#state.socket, Parsed},
@ -330,3 +315,7 @@ route_text(Pid, Data) ->
{text_reply, Pid} ->
ok
end.
-spec route_el(pid(), xmlel() | cdata()) -> ok.
route_el(Pid, Data) ->
route_text(Pid, fxml:element_to_binary(Data)).