25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Don't expose internal FSM API of ejabberd_c2s

This commit is contained in:
Evgeny Khramtsov 2019-07-09 01:01:56 +03:00
parent 9cbc0685db
commit 3e88a0b0b4

View File

@ -1510,16 +1510,24 @@ send_stanza(FromString, ToString, Stanza) ->
{error, "JID malformed"} {error, "JID malformed"}
end. end.
-spec send_stanza_c2s(binary(), binary(), binary(), binary()) -> ok | {error, any()}.
send_stanza_c2s(Username, Host, Resource, Stanza) -> send_stanza_c2s(Username, Host, Resource, Stanza) ->
case {fxml_stream:parse_element(Stanza), try
ejabberd_sm:get_session_pid(Username, Host, Resource)} #xmlel{} = El = fxml_stream:parse_element(Stanza),
of CodecOpts = ejabberd_config:codec_options(),
{{error, Error}, _} -> Pkt = xmpp:decode(El, ?NS_CLIENT, CodecOpts),
{error, Error}; case ejabberd_sm:get_session_pid(Username, Host, Resource) of
{_, none} -> Pid when is_pid(Pid) ->
{error, no_session}; ejabberd_c2s:send(Pid, Pkt);
{XmlEl, C2sPid} -> _ ->
p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}) {error, no_session}
end
catch _:{badmatch, {error, Why} = Err} ->
io:format("invalid xml: ~p~n", [Why]),
Err;
_:{xmpp_codec, Why} ->
io:format("incorrect stanza: ~s~n", [xmpp:format_error(Why)]),
{error, Why}
end. end.
privacy_set(Username, Host, QueryS) -> privacy_set(Username, Host, QueryS) ->